<template>
    <basic-container class="baseContain">
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
            <el-menu-item index="0"><a>当前类目</a></el-menu-item>
            <el-menu-item index="1"><a>基本信息</a></el-menu-item>
            <el-menu-item index="2"><a>自然属性</a></el-menu-item>
            <el-menu-item index="3"><a>规格设置</a></el-menu-item>
            <el-menu-item index="4"><a>店铺内商品分类</a></el-menu-item>
            <el-menu-item index="5"><a>物流信息</a></el-menu-item>
            <el-menu-item index="6"><a>详情描述</a></el-menu-item>
            <el-menu-item index="7"><a>其他信息</a></el-menu-item>
        </el-menu>
        <div class="scrollView" @scroll="contentScroll" ref="contentScroll">
            <avue-form v-model="groupData" :option="optionView" style="padding-top: 15px;">
                <template slot="menuForm">
                    <el-button v-if="!isCheck" type="primary" :loading="submitLoading" size="mini"
						:disabled="isDisabled" @click="handleSubmit">提交
                    </el-button>
                </template>
                <!-- 当前类目 -->
                <template slot="group1Header">
                    <h1 class="avue-group__title">当前类目:</h1>
                    <span style="fontSize:12px;margin:0 30px 0 10px;">{{ goodsclassname }}</span>
                    <el-button type="primary" size="mini" :disabled="isCheck || isRedact" @click.stop="chooseCategory">
                        选择类目
                    </el-button>
                </template>
                <!-- 商品图片 -->
                <template slot="goodsPhotos">
                    <div class="imgContainer">
                        <div class="upload">
                            <el-button size="mini" :disabled="isCheck" type="primary" @click="uploadbtn">上传图片
                            </el-button>
                            <p class="tsmsg">可发布1-10张图片，尺寸750*750</p>
                        </div>
                        <div class="previewPic">
                            <div class="demo-image__preview" style="margin-right:10px;height: 140px;"
                                 v-for="(item, index) in groupData.goodsPhotos" :key="index">
                                <el-image :src="item" style="width: 100px; height: 100px"></el-image>
                                <div class="handlebox">
                                    <div v-if="!isCheck">
                                        <img @click="arrowLeft(index)"
                                             :src="require('../../../../../public/img/placeholderimg/arrow_left.png')"/>
                                        <img @click="arrowDel(index)"
                                             :src="require('../../../../../public/img/placeholderimg/arrow_del.gif')"/>
                                        <img @click="arrowRight(index)"
                                             :src="require('../../../../../public/img/placeholderimg/arrow_right.png')"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </template>

                <!-- 商品视频 -->
                <template slot="goodsVideo">
                    <div class="imgContainer">
                        <div class="upload">
                            <el-button size="mini" :disabled="isCheck" type="primary" @click="uploadVideoBtn">上传视频
                            </el-button>
                            <p class="tsmsg">只能发布一个视频</p>
                        </div>
                        <div class="previewPic">
                            <div class="demo-image__preview" style="margin-right:10px"
                                 v-for="(item, index) in groupData.goodsVideo" :key="index">
                                <video :src="item" class="avatar" controls="controls"></video>
                                <div class="handlebox">
                                    <div v-if="!isCheck"><img @click="videoDel(index)"
                                                              :src="require('../../../../../public/img/placeholderimg/arrow_del.gif')"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </template>
                <template slot="goodsSoRange">
                    <el-select v-model="groupData.goodsSoRangeLabel" @change="changeGClass"   size="mini" placeholder="请选择" multiple collapse-tags>
                        <el-option :value="mineStatusValue" name="name" style="height: auto">
                            <el-tree
                                    :data="signOptions"
                                    :default-expanded-keys="['总分组']"
                                    show-checkbox
									accordion
                                    node-key="id"
                                    ref="tree"
                                    highlight-current
                                    :props="props1"
                                    @check="handleCheckChange"
                            ></el-tree>
                        </el-option>
                    </el-select>
                </template>
                <!--规格配置-->
                <template slot="goodsSpecConfig">
                    <div class="goodsSpecConfig">
                        <div class="specbox" v-for="(item, index) in saleSpecList" :disabled="isCheck" :key="index">
                            <div style="min-width: 80px;">{{ item.specName }}:</div>
                            <div class="ckeckitem">
								<span class="items" v-for="(prop, idx) in item.childrenNodes" :key="idx">
									<el-checkbox
                                            type="checkbox"
                                            @change="handleCheckedChange(index, idx, item.id, prop.isselected,prop.specpValue)"
                                            :value="prop"
                                            :disabled="isCheck || disadledSpec"
                                            :id="prop.specpValue"
                                            v-model="prop.isselected"
                                            style="margin-right: 5px;"
                                    ></el-checkbox>
									<el-image  v-if="item.specModule=='img'&&isPublish" style="width: 30px; height: 30px" class="checkimg" @click="choosePic(index, idx)"
                                               :src="prop.specImageUrl">
                                        <div slot="error" class="image-slot" @click="choosePic(index, idx)">
                                                <i class="el-icon-picture-outline"></i>
                                        </div>
                                    </el-image>
									<el-image v-else-if="item.specModule=='img' && !isPublish" 
                                               :src="prop.specImageUrl"  style="width: 30px; height: 30px">
                                        <div slot="error" class="image-slot">
                                                <i class="el-icon-picture-outline"></i>
                                        </div>
                                    </el-image>
									<el-tooltip class="item" effect="dark" :content="prop.specpValue" placement="top">
										<input v-if="!prop.isselected" maxlength="30" @focus="getFocus(prop.specpValue)" :disabled="isCheck || disadledSpec" @blur="changeSpec(index, idx,prop.specpValue,prop.id)"
											   style="width: 196px;margin-left: 5px;border: 0;" v-model="prop.specpValue"/>
										<input
												v-else
												type="text"
												maxlength="30"
												style="min-width: 50px;margin-left: 5px;border: 0;"
												:disabled="isCheck || disadledSpec"
												@focus="getFocus(prop.specpValue)"
												@blur="changeSpec(index, idx,prop.specpValue,prop.id)"
												@change="handleCheckedChange(index, idx, item.id, prop.isselected,prop.specpValue)"
												v-model="prop.specpValue"
										/>
									</el-tooltip>
								</span>
                                <el-button v-if="isPublish && !isCheck && !isRedact" size="mini" style="background-color:#F39800;color: #fff" round
                                           @click="addChildNode(item.id,index,item)">添加
                                </el-button>
                            </div>
                        </div>
						<div style="overflow-x: scroll;">
							<table width="100%" border="0"  >
							    <tr>
							        <th width="8%">规格</th>
							        <th width="8%">库存</th>
							        <th width="8%">提醒库存量</th>
							        <th width="8%">提醒库存紧张量</th>
							        <th width="8%">商城售价</th>
							        <th width="8%">挂牌价</th>
							        <th width="10%">结算方式</th>
							        <th width="8%">结算价</th>
							        <th width="8%">抽佣比例</th>
							        <th width="8%" v-if="!isPublish">抽佣值</th>
							        <th width="8%">商品条码</th>
							        <th width="10%" style="min-width: 100px;">操作</th>
							    </tr>
							    <tr>
							        <td width="8%"></td>
							        <td width="8%">
							            <input
							                    type="number"
							                    class="specsBox"
							                    min="0"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkGoodsInventory"
							                    v-model="prospec.goodsInventory"
							            />
							        </td>
							        <td width="8%">
							            <input type="number" class="specsBox" min="0" :disabled="isCheck || disadledSpec"
							                   @blur="checkRemindStock" v-model="prospec.remindStock"/>
							        </td>
							        <td width="8%">
							            <input
							                    type="number"
							                    class="specsBox"
							                    min="0"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkTightInventory"
							                    v-model="prospec.tightInventory"
							            />
							        </td>
							        <td width="8%">
							            <input
							                    type="number"
							                    :precision="2"
							                    :min="0.01"
							                    :max="99999999.99"
							                    class="specsBox"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkPrice"
							                    v-model="prospec.price"
							            />
							        </td>
							        <td width="8%">
							            <!-- 挂牌价 -->
							            <input
							                    type="number"
							                    :precision="2"
							                    :min="0.01"
							                    :max="99999999.99"
							                    class="specsBox"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkOriPrice"
							                    v-model="prospec.originalPrice"
							            />
							        </td>
							        <td width="10%">
							            <!-- 结算方式 -->
							            <el-select v-model="prospec.commissionType" placeholder="请选择"
							                       style="width: 95px!important;">
							                <el-option v-for="item in options" :key="item.value" :label="item.label"
							                           :value="item.value"></el-option>
							            </el-select>
							        </td>
							        <td width="8%">
							            <!-- 结算价 -->
							            <input
							                    type="number"
							                    :precision="2"
							                    :max="99999999.99"
							                    class="specsBox"
							                    :disabled="isCheck || disadledSpec || prospec.commissionType == 1"
							                    @blur="checkPurchasePrice"
							                    v-model="prospec.purchasePrice"
							            />
							        </td>
							        <td width="8%">
							            <!-- 抽佣比例 -->
							            <input
							                    type="number"
							                    :precision="2"
							                    :min="0.01"
							                    :max="1"
							                    class="specsBox"
							                    :disabled="isCheck || disadledSpec || prospec.commissionType == 0"
							                    @blur="checkCommissionRate"
							                    v-model="prospec.commissionRate"
							            />
							        </td>
							        <td width="8%" v-if="!isPublish"><input type="number" :precision="2" class="specsBox"
							                                                 :disabled="true"
							                                                 v-model="prospec.commissionValue"/></td>
							        <td width="8%">
							            <input type="text" class="specsBox" :disabled="isCheck || disadledSpec"
							                   @blur="checkGoodsSerial" v-model="prospec.goodsSerial"/>
							        </td>
							        <td width="10%">
							            <el-button type="primary" size="mini" :disabled="isCheck || disadledSpec"
							                       @click="confirmFill">批量填充
							            </el-button>
							        </td>
							    </tr>
							    <tr v-for="(item, index) in tabledata" :key="index">
							        <td class="spectab" style="margin: 0 auto;min-width: 100px;">{{ item.value }}</td>
							        <td>
							            <el-input-number
												size="mini"
							                    v-model="item.goodsInventory"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkGoodsInventory"
							                    controls-position="right"
							                    :min="0"
							            ></el-input-number>
							        </td>
							        <td>
							            <el-input-number
												size="mini"
							                    v-model="item.remindStock"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkRemindStock"
							                    controls-position="right"
							                    :min="0"
							            ></el-input-number>
							        </td>
							        <td>
							            <el-input-number
												size="mini"
							                    v-model="item.tightInventory"
							                    :disabled="isCheck || disadledSpec"
							                    @blur="checkTightInventory"
							                    controls-position="right"
							                    :min="0"
							            ></el-input-number>
							        </td>
							        <td>
							            <el-input-number
												size="mini"
							                    v-model="item.price"
							                    @blur="checkPrice"
							                    :disabled="isCheck"
							                    :precision="2"
							                    :step="1"
							                    :min="0"
							                    :max="99999999.99"
							            ></el-input-number>
							        </td>
							        <td>
							            <!-- 挂牌价 -->
							            <el-input-number
												size="mini"
							                    v-model="item.originalPrice"
							                    @blur="checkOriPrice"
							                    :disabled="isCheck"
							                    :precision="2"
							                    :step="1"
							                    :min="0"
							                    :max="99999999.99"
							            ></el-input-number>
							        </td>
							        <td>
							            <!-- 结算方式 -->
							            <el-select v-model="item.commissionType" :disabled="isCheck" placeholder="请选择">
							                <el-option v-for="item1 in options" :key="item1.value" :label="item1.label"
							                           :value="item1.value"></el-option>
							            </el-select>
							        </td>
							        <td>
							            <!-- 结算价 -->
							            <el-input-number
												size="mini"
							                    v-model="item.purchasePrice"
							                    @blur="checkPurchasePrice"
							                    :disabled="isCheck || item.commissionType == 1"
							                    :precision="2"
							                    :min="0"
							                    :step="1"
							                    :max="99999999.99"
							            ></el-input-number>
							        </td>
							        <td>
							            <!-- 抽佣比例 -->
							            <input class="specsBox" :disabled="isCheck || item.commissionType == 0"
							                   @blur="checkCommissionRate" v-model="item.commissionRate"/>
							        </td>
							        <td v-if="!isPublish">
							            <el-input-number
												size="mini"
							                    v-model="item.commissionValue"
							                    @blur="checkOriPrice"
							                    :disabled="true"
							                    :precision="2"
							                    :step="1"
							                    :min="0"
							                    :max="99999999.99"
							            ></el-input-number>
							        </td>
							        <td><input class="specsBox" :disabled="isCheck" @blur="checkGoodsSerial"
							                   v-model="item.goodsSerial" style="text-indent: 15px;"/></td>
							        <td style="min-width: 100px;"></td>
							    </tr>
							</table>
						</div>
                        
                    </div>
                </template>
                <!-- 店铺分类 -->
                <template slot="userGoodsClassId">
                    <div class="storebox">
                        <el-button type="primary" style="marginRight:20px;" size="mini" :disabled="isCheck"
                                   @click="goodsClassOpen">新增分类
                        </el-button>
                        <el-cascader v-model="value" :disabled="isCheck" :options="cascaderoptions"></el-cascader>
                    </div>
                </template>
                <!-- 运费模板 -->
                <template slot="transportId">
                    <div style="display:flex;">
                        <el-select @change="getTransType" v-model="groupData.transportId" :disabled="isCheck"
                                   placeholder="请选择">
                            <el-option v-for="(item, index) in templateFreightData" :key="index" :label="item.transName"
                                       :value="item.id"></el-option>
                        </el-select>
                        <el-button style="marginLeft:20px" size="mini" type="primary" :disabled="isCheck"
                                   @click="templateFreightHandle">新增运费模板
                        </el-button>
                    </div>
                </template>
                <!-- 商品属性 -->
                <template slot="productsize">
                    <div class="sizebox">
                        <div class="fromRow ">
                            <div class="Name">长度：</div>
                            <el-input style="width:100px;margin-right:5px;" type="number" min="0" size="mini"
                                      :disabled="isCheck" v-model="groupData.goodsLength"></el-input>
                            <i>cm</i>
                        </div>
                        <div class="fromRow ">
                            <div class="Name">宽度：</div>
                            <el-form :rules="goodsWidthRules">
                                <el-input
                                        style="width:100px;margin-right:5px;"
                                        type="number"
                                        min="0"
                                        precision="2"
                                        size="mini"
                                        :disabled="isCheck"
                                        prop="goodsWidth"
                                        v-model="groupData.goodsWidth"
                                ></el-input>
                            </el-form>
                            <i>cm</i>
                        </div>
                        <div class="fromRow ">
                            <div class="Name">高度：</div>
                            <el-input
                                    style="width:100px;margin-right:5px;"
                                    type="number"
                                    min="0"
                                    :precision="2"
                                    size="mini"
                                    :disabled="isCheck"
                                    v-model="groupData.goodsHeight"
                            ></el-input>
                            <i>cm</i>
                        </div>
                        <div class="fromRow ">
                            <div class="Name">体积：</div>
                            <el-input style="width:100px;margin-right:5px;" size="mini" :precision="2" min="0" readonly
                                      :disabled="isCheck" v-model="goodsVolume"></el-input>
                            <i>dm³</i>
                        </div>
                        <div class="fromRow ">
                            <div class="Name">重量：</div>
                            <el-input
                                    style="width:100px;margin-right:5px;"
                                    type="number"
                                    :precision="2"
                                    minRows="0"
                                    min="0"
                                    size="mini"
                                    :disabled="isCheck"
                                    v-model="groupData.goodsWeight"
                            ></el-input>
                            <i>kg</i>
                        </div>
                    </div>
                </template>
                <!-- 商品描述pc -->
                <!--				<template slot="goodsDetails">-->
                <!--					<editor v-if="editorshow" :isCheck="isCheck" :isRedact="isRedact" @getContent="getEditcont" prop="goodsDetails" :cabackcontent="cabackcontent"></editor>-->
                <!--				</template>-->
                <!-- 商品描述h5 -->
                <template slot="goodsDetailsH5">
                    <editor
                            style="width:375px"
                            v-if="editorshow"
                            :isCheck="isCheck"
                            :isRedact="isRedact"
                            @getContent="getEditconth5"
                            prop="goodsDetailsH5"
                            :cabackcontent="cabackcontenth5"
                    ></editor>
                </template>
            </avue-form>
        </div>
        <!-- 选择类目弹窗 -->
        <change-goods-class ref="changeGoods" :isPublish="isPublish" @callback="changeclassdata"
                            :isRedact="isRedact"></change-goods-class>
        <sel-file
                ref="selFile"
                @callback="selFileCallBack"
                imgNum="10"
                albumCode="store"
                dialogTitle="选择图片"
                selectType="checkbox"
                selMaxWidth="300px"
                selMaxHeight="300px"
        ></sel-file>
        <sel-file ref="selVideo" @callback="selVideoCallBack" albumCode="store" dialogTitle="选择视频" selMaxWidth="300px"
                  selMaxHeight="300px" resType="video"></sel-file>
        <sel-file ref="specimg" @callback="specChooseimg" albumCode="store" dialogTitle="选择图片" selectType="radio"
                  selMaxWidth="300px" selMaxHeight="300px"></sel-file>
        <el-dialog title="新增分类" :visible.sync="dialogTableVisible" width="80%" append-to-body>
            <goods-class v-if="dialogTableVisible"></goods-class>
        </el-dialog>
        <el-dialog title="商品提交审核成功" :visible.sync="dialogSuccessVisible" append-to-body width="30%"
                   :close-on-click-modal="false" :show-close="false">
            <div class="boxSuccess">
                <p class="icon-success icon-dui"></p>
                <p class="tip-success">提交审核成功</p>
                <router-link to="/base/goods/seller/addGoods" @click.native="keepOnPost" style="margin-right: 30px;">
                    继续发布商品
                </router-link>
                <router-link to="/base/goods/seller/goods">查看商品</router-link>
            </div>
        </el-dialog>
        <el-dialog title="新增规格" ref="addchildprop" :visible.sync="childdialog" width="50%" :before-close="beforeClose">
            <el-form :model="childData" :rules="childrules" ref="childData" label-width="80px" size="mini">
                <el-form-item label="规格值" prop="specpValue">
                    <el-col :span="22">
                        <el-input v-model="childData.specpValue"></el-input>
                    </el-col>
                </el-form-item>
                <el-form-item label="图片" v-if="type=='img'">
                    <el-image style="width: 100px; height: 100px" v-if="childData.specImageUrl" :src="childData.specImageUrl">
                        <div slot="error" class="image-slot">
                            <i class="el-icon-picture-outline" style="font-size: 100px"></i>
                        </div>
                    </el-image>
					<el-form-item>
					    <el-button type="primary" @click="uploadimg">上传图片</el-button>
					</el-form-item>
                </el-form-item>
                
            </el-form>
            <span slot="footer" class="dialog-footer">
				<el-button type="primary" :disabled="addDisabled" @click="handlechildsubmit('childData')" size="mini">提交</el-button>
				<el-button type="default" @click="clearAddfrom" size="mini">清空</el-button>
			</span>
        </el-dialog>
        <template-freight ref="templatefre" whichType="addTransport" @success="addsuccess"></template-freight>
        <sel-file @callback="selFileCallBackChild" ref="selFileChild" albumCode="pic_root" dialogTitle="选择图片" selectType="radio"
                  selMaxWidth="300px" selMaxHeight="300px"></sel-file>
    </basic-container>
</template>
<script>
    import {
        getGoodsBrand, //请求商品分类接口
        getGoodsClassFour,
        loadClassSpec,
        getStoreCate,
        getsupplierlist,
        gettemplateFre,
        submitdata,
        getProductdata,
        getProductdataInfo,
        goodsSoListTree,
        getOrganizationMapByLevel,
        getTreeSelect,
        addSpecproperty
    } from '@/api/base/goods/addGoods';
	import {listTreeBylevelM} from '@/api/base/operations/advertManage/advert';
    import {testStoreStatus} from '@/api/base/store/seller/storeInfo';
    import {
        testSpeValue
    } from '@/util/util'
    import {viewTemplate} from '@/api/base/store/seller/transport';
    import selFile from '@/components/file/selFile';
    import changeGoodsClass from '@/components/goods/seller/changeGoodsClass';
    import goodsClass from '@/views/base/goods/seller/goodsClass';
    import editor from '@/components/editor/richTextEditor';
    import templateFreight from '@/components/goods/seller/templateFreight';
    import {
        testPirce,
        testPirceZero,
        testGoodsWidth,
        testGoodsSerial,
        testPercentageCommission,
        testGoodsName,
        testGoodsSort,
        testGoodsInventory
    } from '@/util/util';
    import {validatPrice, validatPrice1, testCommissionRate} from '@/util/validate.js';

    var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
    export default {
        name: 'addGoods',
        props: {
            isPublish: {
                //是否发布
                type: Boolean,
                default() {
                    return true;
                }
            },
            isCheck: {
                //是否查看
                type: Boolean,
                default() {
                    return false;
                }
            },
            isRedact: {
                //是否编辑
                type: Boolean,
                default() {
                    return false;
                }
            },
            disadledSpec: {
                type: Boolean,
                default() {
                    return false;
                }
            },
            goodsId: {
                type: String
            }
        },
        components: {
            changeGoodsClass,
            selFile,
            goodsClass,
            editor,
            templateFreight
        },
        computed: {
            goodsVolume() {
                //计算体积
                let tj = null;
                if (this.groupData['goodsLength'] != null && this.groupData['goodsWidth'] != null && this.groupData['goodsHeight'] != null) {
                    tj = (this.groupData['goodsLength'] * this.groupData['goodsWidth'] * this.groupData['goodsHeight']) / 1000;
                    tj = tj.toFixed(2);
                }
                return tj;
            }
        },
        data() {
            return {
                isFirst:true,
                addDisabled:false,
                specId:'',
                pIndex:0,
                cIndex:0,
                loadBtnchild: false,
                childdialog: false, // 新增属性
                childData: {
                    specpValue: '', //规格值
                    specImageUrl: '', //图片
                },
                childrules: {
                    specpValue: [{
                        required: true,
                        message: '请输入规格值',
                        trigger: 'blur'
                    }, {
                        required: true,
                        validator: testSpeValue,
                        trigger: 'blur'
                    }],
                    specImageUrl: [{
                        required: true,
                        message: '请上传图片'
                    }],
                },
                isCanUpPic: false,
                signOptions: [],
                props1: {
                    label: 'name',
                    id: 'id',
                    children: 'childrenNodes'
                },
                mineStatusValue: [],
                distributionValues: [],
                options: [
                    {
                        label: '结算价',
                        value: 0
                    },
                    {
                        label: '抽佣比例',
                        value: 1
                    }
                ],
                isGoodsSerial: false,
                goodsSerialError: '',
                isPurPrice: false,
                purPriceError: '',
                isRate: false,
                commissionRateError: '',
                isOriPrice: false,
                oriPriceError: '',
                isPrice: false,
                priceError: '',
                isGoodsInventory: false,
                goodsInventoryError: '',
                isRemindStock: false,
                remindStockError: '',
                isTightInventoryError: '',
                isTightInventory: false,
                isEditFirst: true, //是否是刚刚打开编辑界面，用来回显运费模板
                isDisabled: false,
                transType: '', //运费模板类型
                goodsStoreId: '', //商品所在的店铺id
                submitLoading: false,
                editorshow: false,
                //cabackcontent: '',
                cabackcontenth5: '',
                checked: true,
                goodsclassname: '',
                dialogSuccessVisible: false,
                dialogTableVisible: false, //选择商品分类弹窗
                goodsClassId: null, //商品分类id
                value: [],
                cascaderoptions: [],
                optionView: {
                    //表单组配置
                    card: true,
                    size: 'mini',
                    mock: false,
                    submitBtn: false,
                    emptyBtn: false,
                    menuPostion: 'right',
                    labelWidth: '130',
                    group: [
                        {
                            prop: 'group1'
                        },
                        {
                            label: '基本信息',
                            prop: 'group2',
                            column: [
                                {
                                    disabled: this.isCheck,
                                    label: '税务品类名称',
                                    prop: 'goodsClassFourId',
                                    type: 'select',
                                    formslot: false,
                                    dicData: [],
                                    required: true,
                                    rules: [{
										// required: true, 
										message: '请选择税务品类名称', 
										trigger: 'blur',
									}]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '商品名称',
                                    prop: 'goodsName',
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    tip:
                                        '名称结构:中文品牌(英文品牌) +商品名称+基本属性(材质/功能/特征) +规格参数(型号/颜色/规格/用途)。示例:亚都(YADU)空气净化器家用除甲醛雾霾负离子加湿型KJ455G-S4D 蓝色',
                                    tipPlacement: 'bottom',
                                    span: 12,
                                    rules: [{required: true, message: '必须填写商品名称', trigger: 'blur'}, {
                                        required: true,
                                        trigger: 'blur',
                                        validator: testGoodsName
                                    }]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '商品品牌',
                                    prop: 'goodsBrandId',
                                    type: 'select',
                                    formslot: false,
                                    dicData: [],
                                    required: true
                                },

                                {
                                    disabled: this.isCheck || this.disadledSpec,
                                    type: 'radio',
                                    label: '商品类型',
                                    span: 12,
                                    display: true,
                                    prop: 'choiceType',
                                    tipPlacement: 'right',
                                    dicData: [
                                        {
                                            label: '实物商品',
                                            value: 0
                                        },
                                        {
                                            label: '虚拟商品(充值卡、消费券等属于虚拟商品)',
                                            value: 1
                                        }
                                    ]
                                },
                                {
                                    label: '商品标签',
                                    disabled: this.isCheck,
                                    prop: 'goodsLabel',
                                    value: 'goodsLabel',
                                    type: 'select',
                                    dicData: Dict.Goods_Label_Enum,
                                    searchSpan: 12,
                                    multiple: true
                                },
                                {
                                    label: '商品服务保障',
                                    disabled: this.isCheck,
                                    prop: 'goodsServeGuarantee',
                                    type: 'tree',
                                    dicUrl: '/api/sellerDict/listDictsByCode?dictTypeCode=GOODS_SERVE_GUARANTEE',
                                    dicMethod: 'post',
                                    multiple: true,
                                    props: {
                                        label: 'name',
                                        value: 'dictId'
                                    },
                                    searchSpan: 12
                                },
                                {
                                    label: '商品可见范围',
                                    disabled: this.isCheck,
                                    formslot: true,
                                    prop: 'goodsSoRange',
                                    span: 12,
									rules: [{required: true, message: '必须选择商品可见范围',trigger: 'blur'}]
                                },
                                {
                                    label: '商品图片',
                                    disabled: this.isCheck,
                                    prop: 'goodsPhotos',
                                    formslot: true,
                                    span: 24,
                                    rules: [{required: true, message: '必须选择商品图片'}]
                                },
                                {
                                    label: '商品视频',
                                    prop: 'goodsVideo',
                                    formslot: true,
                                    span: 24
                                }
                            ]
                        },
                        {
                            prop: 'group3',
                            label: '自然属性',
                            column: []
                        },
                        {
                            prop: 'group4',
                            label: '规格设置',
                            column: [
                                {
                                    disabled: this.isCheck || this.disadledSpec,
                                    type: 'radio',
                                    label: '库存配置',
                                    span: 13,
                                    display: true,
                                    prop: 'inventoryType',
                                    tip: '全局配置表示所有规格无单独库存、价格配置 规格配置需要配置对应属性的库存、价格',
                                    tipPlacement: 'right',
                                    dicData: [
                                        {
                                            label: '单规格',
                                            value: 'all'
                                        },
                                        {
                                            label: '多规格',
                                            value: 'spec'
                                        }
                                    ]
                                },
                                {
                                    label: '商品条码',
                                    disabled: this.isCheck,
                                    prop: 'goodsSerial',
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    display: true,
                                    tip: '商品条码是指卖家个人管理商品的条码，买家不可见，由5-15位数字或者字母组成',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [
                                        {trigger: 'blur', validator: testGoodsSerial}
                                        // testGoodsSerial
                                    ]
                                },
                                {
                                    label: '商品库存',
                                    disabled: this.isCheck || this.disadledSpec,
                                    prop: 'goodsInventory',
                                    type: 'input',
                                    minRows: 0,
                                    maxlength: 50,
                                    required: true,
                                    display: true,
                                    tip: '商品库存数量只能是0-1000000之间的整数',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [{required: true, message: '必须填写商品库存'}, {
                                        required: true,
                                        trigger: 'blur',
                                        validator: testGoodsInventory
                                    }]
                                },
                                {
                                    label: '提醒库存数 ',
                                    disabled: this.isCheck || this.disadledSpec,
                                    prop: 'remindStock',
                                    type: 'input',
                                    minRows: 0,
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    display: true,
                                    tip: '提醒库存数数量只能是0-1000000之间的整数',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [{required: true, message: '必须填写提醒库存数'}, {validator: testGoodsInventory}]
                                },
                                {
                                    label: '提醒库存紧张数',
                                    disabled: this.isCheck || this.disadledSpec,
                                    prop: 'tightInventory',
                                    type: 'input',
                                    minRows: 0,
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    display: true,
                                    tip: '提醒库存紧张数数量只能是0-1000000之间的整数',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [{required: true, message: '必须填写提醒库存紧张数'}, {validator: testGoodsInventory}]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '商城售价',
                                    prop: 'price',
                                    precision: 2,
                                    minRows: 0.01,
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    display: true,
                                    tip: '价格必须是0.01-99999999.99之间的数字',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [{required: true, message: '必须填写商品价格'}, {
                                        required: true,
                                        trigger: 'blur',
                                        validator: testPirce
                                    }]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '挂牌价',
                                    prop: 'originalPrice',
                                    minRows: 0,
                                    precision: 2,
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    display: true,
                                    tip: '挂牌价必须是0.01-99999999.99之间的数字',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [{required: true, message: '必须填写商品挂牌价'}, {
                                        required: true,
                                        trigger: 'blur',
                                        validator: testPirce
                                    }]
                                },
                                {
                                    label: '结算方式',
									disabled: this.isCheck || this.disadledSpec,
                                    prop: 'commissionType',
                                    type: 'radio',
                                    row: true,
                                    span: 13,
                                    valueDefault: 0,
                                    dicData: [
                                        {
                                            label: '结算价',
                                            value: 0
                                        },
                                        {
                                            label: '抽佣比例',
                                            value: 1
                                        }
                                    ],
                                    rules: [{required: true, message: '必须选择结算方式', trigger: 'blur'}]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '结算价',
                                    prop: 'purchasePrice',
                                    precision: 2,
                                    minRows: 0,
                                    display: true,
                                    formslot: false,
                                    maxlength: 50,
                                    required: true,
                                    tip: '结算价必须是0-99999999.99之间的数字',
                                    tipPlacement: 'right',
                                    span: 13,
                                    rules: [{required: true, trigger: 'blur', validator: testPirceZero}]
                                },
                                {
                                    label: '抽佣比例',
                                    prop: 'commissionRate',
                                    disabled: this.isCheck,
                                    display: false,
                                    tip: '最大值是1，最小值0.01',
                                    precision: 2,
                                    span: 13,
                                    minRows: 0.01,
                                    maxRows: 1,
                                    rules: [
                                        {
                                            required: true,
                                            validator: testPercentageCommission,
                                            trigger: 'blur'
                                        }
                                    ]
                                },
                                {
                                    label: '抽佣值',
                                    disabled: true,
                                    span: 13,
                                    display: true,
                                    type: 'input',
                                    prop: 'commissionValue'
                                },
                                {
                                    prop: 'goodsSpecConfig',
                                    formslot: true,
                                    display: false,
									labelWidth:5,
                                    span: 24
                                }
                            ]
                        },
                        {
                            prop: 'group5',
                            label: '店铺内商品分类',
                            column: [
                                {
                                    prop: 'userGoodsClassId',
                                    label: '店铺内商品分类',
                                    formslot: true,
                                    display: true
                                }
                            ]
                        },
                        {
                            prop: 'group6',
                            label: '物流信息',
                            column: [
                                {
                                    disabled: this.isCheck,
                                    type: 'radio',
                                    display: true,
                                    span: 8,
                                    label: '是否自提',
                                    prop: 'isSelfMention',
                                    dicData: [
                                        {
                                            label: '否',
                                            value: 0
                                        },
                                        {
                                            label: '是',
                                            value: 1
                                        }
                                    ]
                                },
                                {
                                    disabled: this.isCheck,
                                    prop: 'storeWillCallId',
                                    type: 'select',
                                    display: false,
                                    span: 8,
                                    label: '自提点',
                                    dicUrl: '/base/storeWillCall/list',
                                    props: {
                                        label: 'storeName',
                                        value: 'id'
                                    },
                                    rules: [
                                        {
                                            required: true,
                                            trigger: 'change',
                                            message: '请选择自提点'
                                        }
                                    ]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '配送范围',
                                    type: 'tree',
                                    // dicUrl:'/base/area/getTreeSelect',
                                    dicData: [],
                                    prop: 'distributionAreaId',
                                    value: 'distributionAreaId',
                                    display: false,
                                    span: 8
                                },
                                {
                                    disabled: this.isCheck,
                                    type: 'radio',
                                    display: true,
                                    span: 24,
                                    label: '供货方式',
                                    prop: 'isSelfSupply',
                                    dicData: [
                                        {
                                            label: '自供货',
                                            value: 0
                                        },
                                        {
                                            label: '供货商',
                                            value: 1
                                        }
                                    ]
                                },
                                {
                                    label: '供货商',
                                    disabled: this.isCheck,
                                    formslot: false,
                                    display: false,
                                    span: 12,
									filterable:true,
                                    prop: 'supplierId',
                                    dicData: [],
                                    type: 'select',
                                    rules: [{required: true, message: '必须填写供货商'}]
                                },
                                {
                                    label: '运费模板',
                                    formslot: true,
                                    display: true,
                                    span: 12,
                                    prop: 'transportId',
                                    rules: [{required: true, trigger: 'blur', message: '必须填写运费模板'}]
                                },
                                {
                                    display: true,
                                    label: '商品属性',
                                    prop: 'productsize',
                                    formslot: true,
                                    span: 24
                                }
                            ]
                        },
                        {
                            prop: 'group7',
                            label: '详情描述',
                            column: [
                                // {
                                // 	disabled: this.isCheck,
                                // 	label: 'PC商品描述',
                                // 	formslot: true,
                                // 	labelWidth: '130',
                                // 	span: 24,
                                // 	prop: 'goodsDetails',
                                // 	rules: [{ required: true, message: '必须填写PC商品描述' }]
                                // },

                                {
                                    disabled: this.isCheck,
                                    label: 'H5商品描述',
                                    formslot: true,
                                    labelWidth: '130',
                                    span: 24,
                                    prop: 'goodsDetailsH5',
                                    rules: [{required: true, message: '必须填写H5商品描述'}]
                                }
                            ]
                        },
                        {
                            prop: 'group8',
                            label: '其他信息',
                            column: [
                                //商品发布页面的商品推荐是店铺推荐storeRecommend
                                {
                                    disabled: this.isCheck,
                                    type: 'radio',
                                    hide: true,
                                    span: 24,
                                    label: '店铺内推荐位',
                                    prop: 'storeRecommend',
                                    dicData: [
                                        {
                                            label: '是',
                                            value: 1
                                        },
                                        {
                                            label: '否',
                                            value: 0
                                        }
                                    ]
                                },
                                {
                                    disabled: this.isCheck,
                                    label: '商品权重',
                                    prop: 'goodsSort',
                                    formslot: false,
                                    required: true,
                                    tip: '权重越小越靠前，最大不超过999',
                                    tipPlacement: 'right',
                                    span: 12,
                                    rules: [{required: true, message: '必须填写商品权重'}, {
                                        required: true,
                                        trigger: 'blur',
                                        validator: testGoodsSort
                                    }]
                                }
                            ]
                        }
                    ]
                },
                goodsClassSpecIds: [], //商品分类id
                templateFreightData: [], //运费模板列表
                storeCateData: [], //店铺分类
                tablelistdata: [], //表格数据
                tabledata: [],
                isFill: false, //是否填充
                parentindex: 0, //选中数据在父级中的下标定位
                childrenindex: 0, //选中数据在当前下标定位
                specSelectData: [],
                productBrandData: [], //商品品牌分类数据
                productClassData: [], //商品品牌分类数据
                activeIndex: '0', //导航当前点击下标
                naturalSpecList: [], //自然属性列表
                saleSpecList: [], //规格设置列表
                oldValue: '', //未改变规格值
                groupData: {
                    //整个商品发布from表单双向绑定数据
                    goodsName: '', //商品名称
                    goodsBrandId: '', //商品品牌
                    goodsClassFourId:'',//商品四级分类
                    choiceType: 0, //商品类型
                    goodsLabel: '',
                    goodsServeGuarantee: [],
                    goodsSoRange: [],
                    goodsPhotos: [], //商品图片
                    goodsVideo: [], //商品视频
                    goodsPropertyIds: [], //商品自然属性
                    inventoryType: 'all', //库存配置 全局配置all   规格配置为spec
                    goodsSerial: '', //商品条码
                    value: '', //商品规格
                    goodsInventory: '', //商品库存
                    price: null, //商品价格
                    originalPrice: null, //商品挂牌价
                    purchasePrice: null, //商品结算价
                    commissionType: 0, //商品结算方式
                    remindStock: null, //提醒库存数
                    tightInventory: null, //提醒库存紧张数
                    commissionRate: null, //抽佣比例
                    commissionValue: null, //抽佣值
                    userGoodsClassId: '', //店铺分类id
                    supplierId: null, //供货商id
                    isSelfMention: 0, //自提点id
                    storeWillCallId: '', //自提点id
                    isSelfSupply: 0, //供货方式
                    transportId: null, //运费模板
                    goodsLength: null, //长度
                    goodsWidth: null, //宽度
                    goodsHeight: null, //高度
                    goodsWeight: null, //重量
                    goodsVolumeWeight: null, //体积重量
                    storeRecommend: 1, //是否推荐
                    goodsSort: null, //商品权重
                    //goodsDetails: '', //商品详情
                    goodsDetailsH5: '' //商品详情H5
                },
                prospec: {
                    goodsInventory: '', //填充库存
                    remindStock: '', //提醒库存数
                    tightInventory: '', //提醒库存紧张数
                    price: '', //填充售卖价格
                    originalPrice: '', //填充商品挂牌价
                    commissionType: 0, //填充商品结算方式
                    purchasePrice: '', //填充商品结算价
                    commissionRate: '', //抽佣比例
                    commissionValue: '', //抽佣值
                    goodsSerial: '' //填充商品条码
                },
                groupHeights: [],
                goodsWidthRules: {
                    goodsWidth: [
                        {
                            required: true,
                            validator: testGoodsWidth,
                            trigger: 'blur'
                        }
                    ]
                },
                fourLevel: [],
				type:'',
                isEditSoRange: false,//是否编辑过商品可见范围
            };
        },
        watch: {
            tabledata(val) {
                console.log(val);
            },
            isPublish(val) {
                console.log('val');
                console.log(val);
            },
            'groupData.inventoryType'(val) {
                var column1 = this.optionView.group[3].column[1];
                var column2 = this.optionView.group[3].column[2];
                var column3 = this.optionView.group[3].column[3];
                var column4 = this.optionView.group[3].column[4];
                var column5 = this.optionView.group[3].column[5];
                var column6 = this.optionView.group[3].column[6];
                var column7 = this.optionView.group[3].column[7];
                var column8 = this.optionView.group[3].column[8];
                var column9 = this.optionView.group[3].column[9];
                var column10 = this.optionView.group[3].column[10];
                var column11 = this.optionView.group[3].column[11];
                if (val === 'spec') {
                    column1.display = false;
                    column2.display = false;
                    column3.display = false;
                    column4.display = false;
                    column5.display = false;
                    column6.display = false;
                    column7.display = false;
                    column8.display = false;
                    column9.display = false;
                    column11.display = true;
                } else {
                    //多规格
                    column1.display = true;
                    column2.display = true;
                    column3.display = true;
                    column4.display = true;
                    column5.display = true;
                    column6.display = true;
                    column7.display = true;
                    column10.display = false;
                    console.log(column10);
                    if (this.groupData.commissionType == 0) {
                        column9.display = false;
                        column8.display = true;
                    } else {
                        column9.display = true;
                        column8.display = false;
                    }
                    column11.display = false;
                }
            },
            'groupData.isSelfSupply'(val) {
                var column = this.optionView.group[5].column[4];
                //切换状态是重置原来选中的运费模板
                this.groupData.transportId = '';
                if (val == 0) {
                    column.display = false;
                    this.groupData.supplierId = '';
                    this.gettemplateFre('');
                } else {
                    column.display = true;
                    this.groupData.supplierId = '';
                    this.templateFreightData = [];
                }
            },
            'groupData.isSelfMention'(val) {
                // if (val == 0) {
                //     this.optionView.group[5].column[1].display = false;
                // } else {
                //     this.optionView.group[5].column[1].display = true;
                // }
            },
            'groupData.supplierId'(val) {
                if (val != '') {
                    //当时是编辑界面时，并且是第一次打开时，不置空运费模板id,其他情况切换供货商就置空运费模板id
                    if (!this.isPublish && this.isEditFirst) {
                        this.isEditFirst = false;
                    } else {
                        this.groupData.transportId = '';
                    }
                    this.gettemplateFre(val);
                }
            },
            'groupData.choiceType'(val) {
                var column = this.optionView.group[5].column[5];
                var columnAttributes = this.optionView.group[5].column[6];
                if (val == '0') {
                    //实物商品    显示运费模板,商品属性
                    column['display'] = true;
                    columnAttributes['display'] = true;
                } else {
                    //虚拟商品   隐藏运费模板,商品属性
                    column['display'] = false;
                    columnAttributes['display'] = false;
                    this.groupData.transportId = '';
                }
            },
            'groupData.commissionType'(val) {
                if (val == 0) {
                    //结算价
                    this.optionView.group[3].column[8].display = true;
                    this.optionView.group[3].column[9].display = false;
                    if (this.groupData.purchasePrice == 0) {
                        this.groupData.purchasePrice = '';
                    }
                } else if (val == 1) {
                    if (this.groupData.commissionRate == 0) {
                        this.groupData.commissionRate = '';
                    }
                    this.optionView.group[3].column[8].display = false;
                    this.optionView.group[3].column[9].display = true;
                }
            },
            dialogTableVisible() {
                if (!this.dialogTableVisible) {
                    this.cascaderoptions = [];
                    this.getStoreCate();
                }
            }
        },
        created() {
            getTreeSelect().then(res => {
                this.optionView.group[5].column[2].dicData = res.data.data;
            });
            //发布商品或者编辑商品的时候在校验
            if (this.isPublish || this.isRedact) {
                //校验一下该店铺状态，看能不能发布商品
                testStoreStatus().then(res => {
                    if (res.data.code == 200) {
                        let backStoreStatus = res.data.data;
                        for (let item of Dict.STORE_STATUS_TYPE) {
                            if (item.label == '正常营业') {
                                if (item.value == backStoreStatus) {
                                    this.isCanUpPic = true;
                                }
                            }
                            if (item.label == '歇业待审核') {
                                if (item.value == backStoreStatus) {
                                    this.isCanUpPic = true;
                                }
                            }
                            if (item.label == '申请恢复正常营业') {
                                if (item.value == backStoreStatus) {
                                    // this.isApplicationBusiness = true;
                                    this.$message({
                                        type: 'error',
                                        message: '该店铺处于"申请恢复正常营业"状态，暂不能发布商品'
                                    });
                                }
                            }
                        }
                    } else {
                        this.isCanUpPic = false;
                        // this.isApplicationBusiness = false;
                    }
                });
            }

            this.$EventBus.$on('scrollTop', () => {
                // console.log(this.$refs.contentScroll.scrollTop);
                // this.activeIndex = '0'
                // this.$refs.contentScroll.scrollTop = 0;
            });
            if (this.fourLevel.length == 0) {
                getOrganizationMapByLevel({level: 4}).then(res => {
                    if (res.data.code == 200) {
                        this.fourLevel = res.data.data;
                    }
                });
            }
            if (this.isPublish) {
                goodsSoListTree('').then(res => {
                    if (res.data.code == 200) {
                        this.signOptions = res.data.data;
                    }
                });
            }
            var column10 = this.optionView.group[3].column[10];
            if (this.isPublish) {
                column10.display = false;
                this.editorshow = true;
            } else {
                column10.display = true;
                this.editorshow = false;
            }
            //如果是商品发布或者商品编辑  请求商品分类数据
            if (this.goodsId !== undefined) {
                //根据商品id请求数据
                getProductdata(this.goodsId).then(async res => {
                    if (res.data.code == 200) {
                        let data = res.data.data;
						listTreeBylevelM(4).then(res => {
							if (res.data.code == 200) {
								// this.signOptions = res.data.data;
								// this.signOptions.forEach(item => {
								// 	item.disabled = true; //可选
								// 	item.childrenNodes.forEach(obj => {
								// 		obj.disabled = true; //可选
								// 		obj.childrenNodes.forEach(nodes => {
								// 			nodes.disabled = true; //可选
								// 			nodes.childrenNodes.forEach(child=>{
								// 				child.disabled = true; //可选
								// 			})
								// 		});
								// 	});
								// });
								let storeSoRange = data.showData.storeSoRange.split(','); //商品可选的范围
								let storeSoRange1= []
								storeSoRange.forEach(item=>{
									storeSoRange1.push(Number(item))
								})
								//设置树的禁选项
								this.setStoreSoRange1(res.data.data,storeSoRange1);
							}
						});
                        console.log(data,'基本信息------')
                        this.goodsStoreId = data.showData.storeId;
                        let arr = [
                            data.showData.allExceptSpecList[0].goodsClassOutName,
                            data.showData.allExceptSpecList[0].goodsClassInChildName,
                            data.showData.allExceptSpecList[0].goodsClassInnerChildName
                        ];
                        this.goodsclassname = arr.join('>>'); //商品类目
                        this.goodsClassId = data.showData.allExceptSpecList[0].goodsClassInnerChildId;
                        this.groupData.goodsName = data.showData.goodsName; //显示商品名称
                        if (data.showData.isSelfMention) {
                            this.groupData.isSelfMention = 1;
                        } else {
                            this.groupData.isSelfMention = 0;
                        }
                        //得到商品分类id去请求商品品牌数据
                        await this.getGoodsBrand(this.goodsClassId);
                        await this.getGoodsClassFour(this.goodsClassId);
                        // //获取店铺分类
                        //this.getStoreCate();
                        //加载运费模板 自供货状态下
                        this.groupData.inventoryType = data.showData.inventoryType; //商品配置  全局  规格
                        if (data.showData.inventoryType == 'all') {
                            //全局配置
                            this.groupData.goodsInventory = data.showData.skuTableInfo[0].goodsInventory;
                            this.groupData.goodsSerial = data.showData.skuTableInfo[0].goodsSerial || '';
                            this.groupData.originalPrice = data.showData.skuTableInfo[0].originalPrice;
                            this.groupData.price = data.showData.skuTableInfo[0].price;
                            this.groupData.purchasePrice = data.showData.skuTableInfo[0].purchasePrice;
                            this.groupData.commissionRate = data.showData.skuTableInfo[0].commissionRate;
                            this.groupData.commissionValue = data.showData.skuTableInfo[0].commissionValue;
                            this.groupData.commissionType = data.showData.skuTableInfo[0].commissionType;
                            this.groupData.remindStock = data.showData.skuTableInfo[0].remindStock;
                            this.groupData.tightInventory = data.showData.skuTableInfo[0].tightInventory;
                        } else {
                            //规格配置
                            //筛选规格设置选中数据
                            this.optionView.group[3].column[10].display = false;
                            if (data.showData.gsptyInfoList) {
                                this.specSelectData = data.showData.gsptyInfoList.filter(item => {
                                    //规格设置选中数据
                                    if (item.specpType == 0) return item;
                                });
                            }
                            //获取全部规格设置
                            let allSaleSpec = data.allSpecInfo.filter(item => {
                                //规格设置
                                if (item.specType == 0) return item;
                            });
                            //设置规格设置选中状态
                            allSaleSpec.forEach(item => {
                                item.childrenNodes.forEach(prop => {
                                    this.specSelectData.forEach(item => {
                                        if (item['id'] == prop['id']) {
                                            prop.isselected = true;
                                            prop.specImageUrl = item['specImageUrl'];
                                            prop.specpValue = item['specpValue'];
                                        }
                                    });
                                });
                            });
                            //规格设置选中数据
                            this.saleSpecList = allSaleSpec;
                            //封装tablelistData
                            this.saleSpecList.forEach(item => {
                                let arr = item.childrenNodes.filter(prop => {
                                    if (this.arrayFn.constansObjByKey(this.specSelectData, prop, 'id')) {
                                        return prop;
                                    }
                                });
                                if (arr.length > 0) {
                                    this.tablelistdata = this.arrayFn.insertAndUpdateObjByKey(
                                        this.tablelistdata,
                                        {
                                            specdata: arr,
                                            specId: item.id
                                        },
                                        'specId'
                                    );
                                }
                            });
                            //生成规格表格
                            this.generateTable();
                            this.tabledata.forEach(item => {
                                data.showData.skuTableInfo.forEach((prop, idx) => {
                                    if (this.isTrue(item.ids.split('_'), prop.ids.split('_'))) {
                                        this.$nextTick(() => {
                                            this.tabledata[idx]['ids'] = prop.ids;
                                            this.tabledata[idx]['value'] = prop.value;
                                            this.tabledata[idx]['goodsInventory'] = prop.goodsInventory;
                                            this.tabledata[idx]['remindStock'] = prop.remindStock || null;
                                            this.tabledata[idx]['tightInventory'] = prop.tightInventory || null;
                                            this.tabledata[idx]['goodsSerial'] = prop.goodsSerial || null;
                                            this.tabledata[idx]['originalPrice'] = prop.originalPrice;
                                            this.tabledata[idx]['price'] = prop.price;
                                            this.tabledata[idx]['purchasePrice'] = prop.purchasePrice;
                                            this.tabledata[idx]['commissionRate'] = prop.commissionRate;
                                            this.tabledata[idx]['commissionValue'] = prop.commissionValue;
                                            this.tabledata[idx]['commissionType'] = prop.commissionType;
                                        });
                                    }
                                });
                            });
                        }
                        this.groupData.transportId = data.showData.allExceptSpecList[2].transportId;
                        this.groupData.supplierId = data.showData.allExceptSpecList[3].supplierId;
                        if (this.groupData.supplierId) {
                            this.groupData.isSelfSupply = 1;
                            setTimeout(() => {
                                this.groupData.supplierId = data.showData.allExceptSpecList[3].supplierId;
                                this.groupData.transportId = data.showData.allExceptSpecList[2].transportId;
                            }, 1000);
                        } else {
                            this.groupData.isSelfSupply = 0;
                        }
                        this.getsupplierlist();
                        this.gettemplateFre(this.groupData.supplierId);
                        this.groupData.choiceType = data.showData.choiceType;
                        this.groupData.goodsLabel = [];
                        if (data.showData.goodsLabel.length > 0) {
                            let goodsLabel = data.showData.goodsLabel.split(',');
                            goodsLabel.forEach(item => {
                                this.groupData.goodsLabel.push(Number(item));
                            });
                        }
                        this.groupData.goodsServeGuarantee = data.showData.goodsServeGuarantee ? data.showData.goodsServeGuarantee.split(',') : '';
                        this.groupData.goodsPhotos = data.showData.goodsPhotos; //图片
                        this.groupData.goodsVideo = data.showData.goodsVideos; //视频
                        this.groupData.goodsLength = data.showData.goodsLength; //长
                        this.groupData.goodsWidth = data.showData.goodsWidth; //宽
                        this.groupData.goodsHeight = data.showData.goodsHeight; //高
                        this.groupData.goodsWeight = data.showData.goodsWeight; //重量
                        this.groupData.goodsBrandId = data.showData.allExceptSpecList[1].brandId; //商品品牌
                        this.groupData.goodsClassFourId = data.showData.allExceptSpecList[0].goodsClassFourId; //商品品牌
                        /*this.cabackcontent = data.showData.goodsDetails;
					this.cabackcontenth5 = data.showData.goodsDetailsH5;*/
                        this.groupData.storeWillCallId = data.showData.storeWillCallId;
                        this.groupData.goodsSort = data.showData.goodsSort;
                        this.groupData.storeRecommend = Number(data.showData.storeRecommend);
                        this.editorshow = true;
                        if (data.showData.userGoodsClass != undefined && data.showData.userGoodsClass != '' && data.showData.userGoodsClass != null) {
                            let storearr = [];
                            storearr.push(data.showData.userGoodsClass.id, data.showData.userGoodsClass.children[0].id);
                            this.value = storearr;
                        }
						this.mineStatusValue=[]
                         this.groupData.goodsSoRange = data.showData.goodsSoRange.split(','); //商品可见范围 配送
                        let mineStatusValue = data.showData.goodsSoRange.split(','); //商品可见范围 配送
                        let goodsval=[];
						this.groupData.goodsSoRangeLabel=[]
						mineStatusValue.forEach(item=>{
							if(this.fourLevel[Number(item)]){
								this.mineStatusValue.push(Number(item))
                                goodsval.push(this.fourLevel[Number(item)])
                                // this.groupData.goodsSoRangeLabel = goodsval;//商品可见范围
							}
						})
                        
						setTimeout(() => {
							console.log('mineStatusValue')
							console.log(this.mineStatusValue)
							this.$refs.tree.setCheckedKeys(this.mineStatusValue);
							setTimeout(() => {
								let res = this.$refs.tree.getCheckedNodes();
								let arrLabel = [];
								res.forEach(item => {
									arrLabel.push(item.name);
								});
								this.groupData.goodsSoRangeLabel = arrLabel
								console.log(this.groupData.goodsSoRangeLabel)
							}, 1000);
						}, 1000);
                        // setTimeout(() => {
                        //     let nodes = this.$refs.tree.getCheckedNodes();
                        //     console.log(nodes);
                        //     this.groupData.goodsSoRange = [];
                        //     nodes.forEach(item => {
                        //         this.groupData.goodsSoRange.push(item.name);
                        //     });
                        // }, 5000);
                        //获取所有自然属性
                        this.naturalSpecList = data.allSpecInfo.filter(item => {
                            //自然属性
                            if (item.specType == 1) return item;
                        });
                        if (this.isCheck) {
                            this.handleNature(true);
                        } else {
                            this.handleNature(true);
                        }
                        //显示的自然属性
                        let gsptyInfoList = [];
                        if (data.showData.gsptyInfoList) {
                            gsptyInfoList = data.showData.gsptyInfoList.filter(item => {
                                //规格设置
                                if (item.specpType == 1) return item;
                            });
                        }
                        //设置自然属性的回显
                        this.naturalSpecList.forEach((item, index) => {
                            gsptyInfoList.forEach(prop => {
                                if (item.id == prop.specId) {
                                    this.groupData[`naturalSelData${index}`] = gsptyInfoList[index].id;
                                }
                            });
                        });
                        this.groupData.distributionAreaId = data.showData.distributionAreaId;
                        console.log(this.groupData);
                        console.log('this.groupData');
						
                        this.$forceUpdate();
                    }
                });

                getProductdataInfo(this.goodsId).then(res => {
                    //this.cabackcontent = res.data.data.goodsDetails;
                    setTimeout(() => {
                        this.cabackcontenth5 = res.data.data.goodsDetailsH5;
                    }, 200);
                });
				
            } else {
                // //加载供货商列表
                this.getsupplierlist();
                //加载运费模板 自供货状态下
                this.gettemplateFre();
            }
        },
        methods: {
			setStoreSoRange1(asignOptions,storeSoRange1){
				console.log(storeSoRange1)
				console.log(asignOptions)
				if(asignOptions.length>0){
					asignOptions.forEach(item => {
						if(storeSoRange1.indexOf(item.id)!=-1){
							item.disabled = false; //可选
							item.childrenNodes.forEach(obj => {
								if(storeSoRange1.indexOf(obj.id)!=-1){
									obj.disabled = false; //可选
									obj.childrenNodes.forEach(nodes => {
										if(storeSoRange1.indexOf(nodes.id)!=-1){ 
											nodes.disabled = false; //可选
											nodes.childrenNodes.forEach(child=>{
												if(storeSoRange1.indexOf(child.id)!=-1){
													child.disabled = false; //可选
												}else{
													child.disabled = true; //不可选
												}	
											})
										}else{
											nodes.disabled = true; //不可选
											nodes.childrenNodes.forEach(child=>{
												child.disabled = true; //不可选
											})
										}
									});
								}else{
									obj.disabled = true; //不可选
									obj.childrenNodes.forEach(nodes => {
										nodes.disabled = true; //不可选
										nodes.childrenNodes.forEach(child=>{
											child.disabled = true; //不可选
										})
									});
								}
							});
						}else{
							item.disabled = true; //不可选
							item.childrenNodes.forEach(obj => {
								obj.disabled = true; //不可选
								obj.childrenNodes.forEach(nodes => {
									nodes.disabled = true; //不可选
									nodes.childrenNodes.forEach(child=>{
										child.disabled = true; //不可选
									})
								});
							});
						}
					});
					console.log(asignOptions)
					this.signOptions = asignOptions;
					this.$forceUpdate();


				}
			},
            beforeClose(done) {
                this.childData = {
                    specpValue: '', //规格值
                    specImageUrl: '', //图片
                    specpSequence: '',//排序号
                    specModule: this.childData.specModule,
                    specName: this.childData.specName,
                };
                this.addDisabled = false
                this.$refs["childData"].clearValidate()
                this.$refs["childData"].resetFields()
                done()
            },
            addChildNode(pId,pIndex,item) {
				console.log(item)
				this.type = item.specModule
                this.specId = pId
                this.pIndex = pIndex
                // this.cIndex = cIndex
                this.childdialog = true
            },
            uploadimg() {
                //上传图片
                this.$refs.selFileChild.open()
            },
            selFileCallBackChild(data) {
                this.childData.specImageUrl = data[0]
            },
            //处理新增子规格提交事件
            handlechildsubmit(childData) {
                console.log('childData',this.childData)
                this.$refs[childData].validate((valid) => {
                    if (valid) {
                        this.addDisabled = true
                        addSpecproperty(Object.assign(this.childData, {
                            specId: this.specId
                        }))
                            .then(res => {
                                if (res.data.code == 200) {
                                    this.$message.success('添加成功')
                                    this.childdialog = false;
                                    this.addDisabled = false
                                    this.saleSpecList[this.pIndex].childrenNodes.push(res.data.data)
                                    this.onLoad(this.page);
                                    this.clearAddfrom()
                                } else {
                                    this.$message.error(res.data.message);
                                    this.addDisabled = false
                                    this.clearAddfrom()
                                    return;
                                }
                            })
                            .catch(err => {
                                this.$message.error(err);
								this.clearAddfrom()
                                this.addDisabled = false
                                return;
                            })
                    } else {
                        this.$message({
                            type: "error",
                            message: "请先填写正确的必要信息!"
                        });
                        this.addDisabled = false
                        return false
                    }
                })

            },
            clearAddfrom() {
                this.childData = {
                    specpValue: '', //规格值
                    specImageUrl: '', //图片
                    specpSequence: '',//排序号
                    specModule: this.childData.specModule,
                    specName: this.childData.specName,
                };
                this.$refs["childData"].clearValidate()
                this.$refs["childData"].resetFields()
            },
			changeGClass(value){
				this.groupData.goodsSoRangeLabel= value.slice(0,value.length-1)
			},
            //可见范围选择事件
            handleCheckChange() {
                this.isEditSoRange = true;
                let res = this.$refs.tree.getCheckedNodes();
                let res1 = this.$refs.tree.getHalfCheckedNodes();
                let arrLabel = [];
                let arr = [];
                res1.forEach((item) => {
                    arr.push(item);
                });
                res.forEach(item => {
                    arrLabel.push(item.name);
                    arr.push(item);
                });
                this.mineStatusValue = arr;
                this.groupData.goodsSoRangeLabel = arrLabel;
                this.groupData.goodsSoRange = arrLabel // 提交时会重新赋值,所以这里暂时赋其他值
                console.log('this.groupData',this.groupData.goodsSoRange)
            },
            //签约区域选择事件
            // distributionHandleCheckChange() {
            // 	console.log('distributionHandleCheckChange');
            // 	let res = this.$refs.postTree.getCheckedNodes();
            // 	let arrLabel = [];
            // 	let arr = [];
            // 	console.log(res);
            // 	res.forEach(item => {
            // 		arrLabel.push(item.name);
            // 		arr.push(item);
            // 	});
            // 	console.log(arrLabel);
            // 	console.log(arr);
            // 	this.distributionValues = arr;
            // 	this.groupData.distributionAreaId = arrLabel;
            // },
            // //删除已选中的所有的
            // distributionRemove(val) {
            // 	this.groupData.distributionAreaId = [];
            // 	this.$refs.postTree.setChecked(val, false);
            // 	let arr = this.$refs.postTree.getCheckedNodes();
            // 	for (let i in arr) {
            // 		this.groupData.distributionAreaId.push(arr[i].name);
            // 	}
            // },
            addsuccess() {
                console.log(`添加运费模成功`);
                this.gettemplateFre(this.groupData.supplierId);
            },
            contentScroll() {
			    if(this.isFirst) {
                    this.activeIndex = '0'
                    this.$refs.contentScroll.scrollTop = 0;
                    this.isFirst = false
                    return
                }
                let scrollTopNum = this.$refs.contentScroll.scrollTop;
				let doms = document.getElementsByClassName('avue-group');
                if (scrollTopNum >= 0 && scrollTopNum < doms[1].offsetTop) {
                    this.activeIndex = '0';
                } else if (scrollTopNum >= doms[1].offsetTop && scrollTopNum < doms[2].offsetTop) {
                    this.activeIndex = '1';
                } else if (scrollTopNum >= doms[2].offsetTop && scrollTopNum < doms[3].offsetTop) {
                    this.activeIndex = '2';
                } else if (scrollTopNum >= doms[3].offsetTop && scrollTopNum < doms[4].offsetTop) {
                    this.activeIndex = '3';
                } else if (scrollTopNum >= doms[4].offsetTop && scrollTopNum < doms[5].offsetTop) {
                    this.activeIndex = '4';
                } else if (scrollTopNum >= doms[5].offsetTop && scrollTopNum < doms[6].offsetTop) {
                    this.activeIndex = '5';
                } else if (scrollTopNum >= doms[6].offsetTop && scrollTopNum < doms[7].offsetTop) {
                    this.activeIndex = '6';
                }
            },
            keepOnPost() {
                //强制刷新页面
                this.$router.go(0);
            },
            // 判断两个数组是否相等
            isTrue(arr, arr1) {
                if (arr.length !== arr1.length) {
                    return false;
                }
                for (let i = 0; i < arr.length; i++) {
                    const item = arr[i];
                    const item1 = arr1[i];
                    if (item['op'] !== item1['op']) {
                        return false;
                    }
                }
                return true;
            },
            /**
             * 请求数据相关方法
             */
            //获取商品品牌
            getGoodsBrand(goodsClassId) {
                getGoodsBrand(goodsClassId).then(res => {
                    if (res.data.code == 200) {
                        this.productBrandData = [];
                        let brand = res.data.data;
                        brand.forEach(item => {
                            this.productBrandData.push(new Object({value: item.id, label: item.brandName}));
                        });
                        this.optionView.group[1].column[2].dicData = this.productBrandData;
                    }
                });
            },
            getGoodsClassFour(goodsClassId){
                getGoodsClassFour(goodsClassId).then(res =>{
                    if (res.data.code == 200) {
                        this.productClassData = [];
                        let fourClass = res.data.data;
                        fourClass.forEach(item => {
                            this.productClassData.push(new Object({value: item.id, label: item.className}));
                        });
                        this.optionView.group[1].column[0].dicData = this.productClassData;

                    }
                });
            },
            //获取商品属性
            loadClassSpec(goodsClassId) {
                loadClassSpec(goodsClassId).then(res => {
                    //在这里过滤出来规格设置和商品属性
                    if (res.data.code == 200) {
                        //自然属性1  规格设置0
                        let data = res.data.data;
                        this.naturalSpecList = data.filter(item => {
                            //自然属性
                            if (item.specType == 1) return item;
                        });
                        this.saleSpecList = data.filter(item => {
                            //规格设置
                            if (item.specType == 0) return item;
                        });
                        this.saleSpecList.forEach(item => {
                            item.childrenNodes.forEach(p => {
                                p.isselected = false;
                            });
                        });
                        this.handleNature(false);
                    }
                });
            },
            handleNature(bool = false) {
                this.naturalSpecList = this.naturalSpecList.map(item => {
                    let arr = item.childrenNodes.map(prop => {
                        return {
                            label: prop.specpValue,
                            value: prop.id
                        };
                    });
                    return {
                        specName: item.specName,
                        id: item.id,
                        childrenNodes: arr
                    };
                });
                //配置自然属性option
                let group = this.optionView.group[2];
                group.column = [];
                this.naturalSpecList.forEach((item, index) => {
                    group.column.push({
                        type: 'select',
                        label: item.specName,
                        dicData: item.childrenNodes,
                        suffixIcon: 'el-icon-tickets',
                        prefixIcon: 'el-icon-tickets',
                        span: 13,
                        display: true,
                        disabled: bool,
                        prop: 'naturalSelData' + index
                    });
                    this.groupData[`naturalSelData${index}`] = '';
                });
            },

            //获取店铺分类数据
            getStoreCate() {
                getStoreCate(this.goodsStoreId).then(res => {
                    if (res.data.code == 200) {
                        let data = res.data.data;
                        data.forEach(item => {
                            let obj = {};
                            obj.value = item.id;
                            obj.label = item.className;
                            obj.children = [];
                            item.children.forEach(prop => {
                                let clilobj = {};
                                clilobj.value = prop.id;
                                clilobj.label = prop.className;
                                obj.children.push(clilobj);
                            });
                            this.cascaderoptions.push(obj);
                        });
                    }
                });
            },
            //加载供货商列表
            getsupplierlist() {
                console.log(this.goodsStoreId);
                getsupplierlist(this.goodsStoreId).then(res => {
                    if (res.data.code == 200) {
                        //获取店铺分类
                        this.getStoreCate();
                        this.optionView.group[5].column[4].dicData = res.data.data.map(item => {
                            return {label: item.title, value: item.id};
                        });
                        //供货商列表
                        this.supplierlist = res.data.data.map(item => {
                            return {label: item.title, value: item.id};
                        });
                    }
                });
            },
            //获取运费模板列表
            gettemplateFre(supplierId = '') {
                supplierId = this.groupData.supplierId;
                gettemplateFre(supplierId, this.goodsStoreId).then(res => {
                    if (res.data.code == 200) {
                        this.templateFreightData = res.data.data;
                    }
                });
            },

            //获取运费模板详情
            // viewTemplate(id) {
            // 	viewTemplate(id).then((res) => {
            // 		if (res.data.code == 200) {
            // 			console.log(res.data.data)
            // 			var transType = res.data.data.transType
            // 			if(transType == 1) {
            // 				if (!this.groupData.goodsWeight) {
            // 					this.$message.error("商品重量不能为空");
            // 					return;
            // 				}
            // 			}else if(transType == 2) {
            // 				if (this.goodsVolume == '') {
            // 					this.$message.error("商品体积不能为空");
            // 					return;
            // 				}
            // 			}
            // 		}
            // 	})
            // },
            /**
             * 处理页面数据逻辑相关
             */
            changeclassdata(val) {
                let bigClass = val.str.substring(0, 4);
                if (bigClass == '生鲜食品') {
                    this.optionView.group[1].column[1].tip = '名称结构:中文品牌(英文品牌) +产地+品种+商品名称+包装规格(数量) +重量。示例:欢乐果园河北精选皇冠梨6个装单果240-270g';
                } else if (bigClass == '本地生活') {
                    this.optionView.group[1].column[1].tip = '名称结构:商家名称+商品名称+使用范围+商品属性。示例:爱康国宾体检卡珍爱精英套餐体检卡男女通用(电子券)';
                } else {
                    this.optionView.group[1].column[1].tip =
                        '名称结构:中文品牌(英文品牌) +商品名称+基本属性(材质/功能/特征) +规格参数(型号/颜色/规格/用途)。示例:亚都(YADU)空气净化器家用除甲醛雾霾负离子加湿型KJ455G-S4D 蓝色';
                }
                //选择分类回调方法，携带分类id
                this.prospec = {
                    goodsInventory: '', //填充库存
                    remindStock: '', //提醒库存量
                    tightInventory: '', //提醒库存紧张量
                    price: '', //填充售卖价格
                    originalPrice: '', //填充商品挂牌价
                    commissionType: 0, //填充商品结算方式
                    purchasePrice: '', //填充商品结算价
                    commissionRate: '', //抽佣比例
                    commissionValue: '', //抽佣值
                    goodsSerial: '' //填充商品条码
                };
                this.productBrandData = [];
                this.groupData.goodsBrandId = '';
                this.groupData.goodsClassFourId = '';
                this.tabledata = [];
                this.specSelectData = [];
                this.tablelistdata = [];
                this.goodsClassSpecIds = val.goodsClassSpecIds;
                this.goodsclassname = val.str;
                this.goodsClassId = val.code;
                //得到商品分类id去请求商品品牌数据
                this.optionView.group[1].column[1].dicData = '';
                this.getGoodsBrand(val.code);
                this.getGoodsClassFour(val.code);
                //获取商品属性
                this.loadClassSpec(val.code);
            },
            handleSelect(el) {
                this.activeIndex = el;
                let scrollDom = document.getElementsByClassName('scrollView')[0];
                let doms = document.getElementsByClassName('avue-group');
                scrollDom.scrollTop = doms[el].offsetTop+2;
            },
            chooseCategory() {
                //控制选择类目弹窗
                this.$refs.changeGoods.open();
            },
            uploadbtn() {
                if (this.isCanUpPic) {
                    //上传图片
                    this.$refs.selFile.open();
                } else {
                    this.$message({
                        type: 'error',
                        message: '该店铺未正常营业，暂不能使用该功能'
                    });
                }
            },
            selFileCallBack(data) {
                console.log(data);
                let len = data.length;
                let viewLen = this.groupData.goodsPhotos.length;
                console.log(viewLen);
                //选中图片传回的数据
                //最多上传5张照片
                if (len <= 10 - viewLen) {
                    this.groupData.goodsPhotos = this.groupData.goodsPhotos.concat(data);
                } else {
                    this.$message({
                        type: 'warning',
                        message: '最多可上传10张图片'
                    });
                    // this.groupData.goodsPhotos = data;
                }
                // this.childData.
            },
            uploadVideoBtn() {
                this.$refs.selVideo.open();
            },
            //选择视频回调
            selVideoCallBack(data) {
                //最多上传1个视频
                if (data.length > 1) {
                    this.$message({
                        type: 'warning',
                        message: '最多可上传1个视频'
                    });
                    return;
                } else {
                    this.groupData.goodsVideo = data;
                }
                console.log(this.groupData.goodsVideo);
            },
            //处理上传图片部分js
            arrowLeft(idx) {
                console.log(this.groupData.goodsPhotos);
                //左移动
                if (idx == 0) {
                    this.$message.warning('已经第一张了');
                } else {
                    let arritem = this.groupData.goodsPhotos.splice(idx, 1);
                    this.groupData.goodsPhotos.splice(idx - 1, 0, ...arritem);
                }
            },
            arrowRight(idx) {
                //右移动
                if (idx == this.groupData.goodsPhotos.length - 1) {
                    this.$message.warning('已经最后一张了');
                } else {
                    let arritem = this.groupData.goodsPhotos.splice(idx, 1);
                    this.groupData.goodsPhotos.splice(idx + 1, 0, ...arritem);
                }
            },
            arrowDel(idx) {
                //删除
                this.groupData.goodsPhotos.splice(idx, 1);
            },
            //删除已上传视频
            videoDel(idx) {
                //删除
                this.groupData.goodsVideo.splice(idx, 1);
            },

            choosePic(index, idx) {
                console.log('index')
                this.parentindex = index;
                this.childrenindex = idx;
				this.$refs.specimg.open();
                //选择规格图片
            },
            specChooseimg(url) {
                //选择规格图片返回的图片链接数据
                this.saleSpecList[this.parentindex].childrenNodes[this.childrenindex].specImageUrl = url[0];
            },
            arrsort(property) {
                return (a, b) => {
                    var val1 = a[property];
                    var val2 = b[property];
                    return val1 - val2;
                };
            },
			getFocus(a){
				this.oldValue = a
			},
			//直接编辑规格值时做校验
			changeSpec(index, idx,value,id){
				let empty=/^\S.*\S$/
				const re = /^[\u4e00-\u9fa5a-zA-Z0-9 *()_\-+=<>:"{}|,;'·&*（）—\-+={}|《》\/：“”【】、；‘'，。.]+$/;  //这是校验不包含特殊符号
				if(!re.test(value)){
					let arr = value.split("")
					let newArr = []
					arr.forEach(item=>{
						if(re.test(item)){
							newArr.push(item)
						}
					})
					this.$message.warning('规格值由1-15位中文，字母，数字或部分特殊字符组成');
					value = newArr.join('')
					if(!empty.test(value)){
						let arr = value.split("")
						if(arr[0]==' '){
							value = value.substring(1,arr.length)
						}
						if(arr[arr.length-1]==' '){
							value = value.substring(0,arr.length-1)
						}
					}
					if(value.length>15){
						value = value.substring(0,15)
					}
					this.saleSpecList[index].childrenNodes[idx].specpValue=value
				}else{
					if(!empty.test(value)&&value.length>1){
						let arr = value.split("")
						if(arr[0]==' '){
							console.log("第一个是空格")
							value = value.substring(1,arr.length)
						}
						if(arr[arr.length-1]==' '){
							console.log("最后一个是空格")
							value = value.substring(0,arr.length-1)
						}
						if(re.test(value)){
							this.$message.warning('规格值不能以空格开始或结束')
						}
					}else if(!empty.test(value)&&value==' '){
						value=''
						this.$message.warning('规格值不能以空格开始或结束')
					}
				}
				if(value==''){
					value = this.oldValue
				}
				if(value.length>30){
					value = value.substring(0,30)
					this.$message.warning('规格值长度位1-30位')
					this.saleSpecList[index].childrenNodes[idx].specpValue=value
				}else{
					this.saleSpecList[index].childrenNodes[idx].specpValue=value
				}
				this.saleSpecList[index].childrenNodes.forEach(child=>{
					if(value==child.specpValue&&child.id!=id){
						this.$message.warning('规格值不能相同')
						this.saleSpecList[index].childrenNodes[idx].specpValue = this.oldValue
					}
				})
				this.generateTable();
			},
            handleCheckedChange(index, idx, id, checked,value) {
                //复选框变化触发事件
                console.log(this.prospec);
				let empty=/^\S.*\S$/
				if(!empty.test(value)&&value.length>1){
					this.$message.warning('规格值不能以空格开始或结束')
					return
				}
				if(!empty.test(value)&&value==' '){
					this.$message.warning('规格值不能以空格开始或结束')
					return
				}
				if(!empty.test(value)&&value==''){
					this.$message.warning('规格值不能以空格开始或结束')
					return
				}
                this.prospec = {
                    goodsInventory: '', //填充库存
                    remindStock: '', //提醒库存量
                    tightInventory: '', //提醒库存紧张量
                    price: '', //填充售卖价格
                    originalPrice: '', //填充商品挂牌价
                    commissionType: 0, //填充商品结算方式
                    purchasePrice: '', //填充商品结算价
                    commissionRate: '', //抽佣比例
                    commissionValue: '', //抽佣值
                    goodsSerial: '' //填充商品条码
                };
                console.log(this.prospec);
                this.parentindex = index;
                this.childrenindex = idx;
                if (checked == true) {
                    this.specSelectData = this.arrayFn.insertAndUpdateObjByKey(this.specSelectData, this.saleSpecList[this.parentindex].childrenNodes[this.childrenindex], 'id');
                } else {
                    this.specSelectData = this.arrayFn.removeObjByKey(this.specSelectData, this.saleSpecList[this.parentindex].childrenNodes[this.childrenindex], 'id');
                }
                console.log(this.specSelectData);
                this.saleSpecList[this.parentindex].childrenNodes = this.saleSpecList[this.parentindex].childrenNodes.map(item => {
                    if (this.arrayFn.constansObjByKey(this.specSelectData, item, 'id')) {
                        //对象被选中
                        item.isselected = true;
                    } else {
                        item.isselected = false;
                    }
                    return item;
                });
                let arr = this.specSelectData.filter(item => {
                    return item.specId == id;
                });
                if (arr.length > 0) {
                    this.tablelistdata = this.arrayFn.insertAndUpdateObjByKey(
                        this.tablelistdata,
                        {
                            specdata: arr,
                            specId: id
                        },
                        'specId'
                    );
                } else {
                    this.tablelistdata = this.arrayFn.removeObjByKey(
                        this.tablelistdata,
                        {
                            specdata: arr,
                            specId: id
                        },
                        'specId'
                    );
                }
                this.generateTable();
            },
            generateTable() {
                //生成sku表格
                this.tabledata = [];
                let trData = [];
                this.tablelistdata.sort(this.arrsort('specId'));
                if (this.tablelistdata.length > 0) {
                    trData = this.generateTable2(trData, '', '', 0);
                }
                if (this.isFill) {
                    //已经填充过属性
                    trData.forEach(item => {
                        for (let prop in item) {
                            if (prop == 'value' || prop == 'ids') {
                                continue;
                            } else {
                                item[prop] = this.prospec[prop];
                            }
                        }
                    });
                    this.tabledata = trData;
                } else {
                    this.tabledata = trData;
                }
            },
            generateTable2(trData, ggName, id, index) {
                //递归生成sku表格
                if (this.tablelistdata.length - 1 <= index) {
                    this.tablelistdata[index].specdata.forEach(item => {
                        var _ggName;
                        var ids;
                        if (ggName == '' || id == '') {
                            _ggName = item.specpValue;
                            ids = item.id;
                        } else {
                            _ggName = ggName + ',' + item.specpValue;
                            ids = id + '_' + item.id;
                        }
                        var tr = {};
                        tr.value = _ggName;
                        tr.ids = ids;
                        tr.goodsInventory = ''; //商品库存
                        tr.remindStock = ''; //提醒库存量
                        tr.tightInventory = ''; //提醒库存紧张量
                        tr.price = ''; //商品售卖价格
                        (tr.originalPrice = ''), //挂牌价
                            (tr.commissionType = 0), //结算方式
                            (tr.purchasePrice = ''), //结算价
                            (tr.commissionRate = ''), //抽佣比例
                            (tr.commissionValue = ''), //抽佣值
                            (tr.goodsSerial = ''), //商品条码
                            trData.push(tr);
                    });
                    return trData;
                } else {
                    this.tablelistdata[index].specdata.forEach(item => {
                        var _ggName;
                        var ids;
                        if (ggName == '') {
                            _ggName = item.specpValue;
                            ids = item.id;
                        } else {
                            _ggName = ggName + ',' + item.specpValue;
                            ids = id + '_' + item.id;
                        }
                        trData = this.generateTable2(trData, _ggName, ids, index + 1);
                    });
                    return trData;
                }
            },
            //库存
            checkGoodsInventory(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isGoodsInventory = true;
                    this.goodsInventoryError = '商品库存不能为空';
                } else {
                    const re = /^[0-9]*$/;
                    const rsCheck = re.test(Number(value));
                    if (!rsCheck) {
                        this.isGoodsInventory = true;
                        this.goodsInventoryError = '商品库存数量只能是0-1000000之间的整数';
                    } else if (Number(value) < 0 || Number(value) > 1000000) {
                        this.isGoodsInventory = true;
                        this.goodsInventoryError = '商品库存数量只能是0-1000000之间的整数';
                    } else {
                        this.isGoodsInventory = false;
                        this.goodsInventoryError = '';
                    }
                }
                // this.prospec.goodsInventory=value
            },
            //提醒库存量
            checkRemindStock(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isRemindStock = true;
                    this.remindStockError = '提醒库存量不能为空';
                } else {
                    const re = /^[0-9]*$/;
                    const rsCheck = re.test(Number(value));
                    if (!rsCheck) {
                        this.isRemindStock = true;
                        this.remindStockError = '提醒库存量只能是0-1000000之间的整数';
                    } else if (Number(value) < 0 || Number(value) > 1000000) {
                        this.isRemindStock = true;
                        this.remindStockError = '提醒库存量只能是0-1000000之间的整数';
                    } else {
                        this.isRemindStock = false;
                        this.remindStockError = '';
                    }
                }
                // this.prospec.goodsInventory=value
            },
            //提醒库存紧张量
            checkTightInventory(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isTightInventory = true;
                    this.isTightInventoryError = '提醒库存紧张量不能为空';
                } else {
                    const re = /^[0-9]*$/;
                    const rsCheck = re.test(Number(value));
                    if (!rsCheck) {
                        this.isTightInventory = true;
                        this.isTightInventoryError = '提醒库存紧张量数量只能是0-1000000之间的整数';
                    } else if (Number(value) < 0 || Number(value) > 1000000) {
                        this.isTightInventory = true;
                        this.isTightInventoryError = '提醒库存紧张量数量只能是0-1000000之间的整数';
                    } else {
                        this.isTightInventory = false;
                        this.isTightInventoryError = '';
                    }
                }
                // this.prospec.goodsInventory=value
            },
            //价格
            checkPrice(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isPrice = true;
                    this.priceError = '商品价格不能为空';
                } else if (!this.testPriceMethod(Number(value))) {
                    this.isPrice = true;
                    this.priceError = '商品价格必须是0.01-99999999.99之间的数字';
                } else {
                    this.isPrice = false;
                    this.priceError = '';
                }
                console.log(this.priceError);
                console.log(this.isPrice);
                // this.prospec.price = value;
            },
            //挂牌价
            checkOriPrice(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isOriPrice = true;
                    this.oriPriceError = '商品挂牌价不能为空';
                } else if (!this.testPriceMethod(Number(value))) {
                    this.isOriPrice = true;
                    this.oriPriceError = '商品挂牌价必须是0.01-99999999.99之间的数字';
                } else {
                    this.isOriPrice = false;
                    this.oriPriceError = '';
                }
                // this.prospec.originalPrice = value;
            },

            //结算价
            checkPurchasePrice(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isPurPrice = true;
                    this.purPriceError = '结算价不能为空';
                } else if (!this.testPriceMethod1(Number(value))) {
                    this.isPurPrice = true;
                    this.purPriceError = '结算价必须是0-99999999.99之间的数字';
                } else {
                    this.isPurPrice = false;
                    this.purPriceError = '';
                }
                // this.prospec.purchasePrice = value
            },
            //抽佣比例
            checkCommissionRate(e) {
                let value = e.target.value;
                if (value === '') {
                    this.isRate = true;
                    this.commissionRateError = '抽佣比例不能为空';
                } else if (testCommissionRate(Number(value))) {
                    this.isRate = true;
                    this.commissionRateError = '抽佣比例必须是0.01-1之间的数字';
                } else {
                    this.isRate = false;
                    this.commissionRateError = '';
                }
                // this.prospec.purchasePrice = value
            },
            //商品条码
            checkGoodsSerial(e) {
                let value = e.target.value;
                if (value === '') {
                    // this.isGoodsSerial = true;
                    // this.goodsSerialError = '商品条码输入不可以为空';
                } else {
                    const re = /^[A-Za-z0-9-_\./\u4e00-\u9fa5]{1,50}$/;
                    const rsCheck = re.test(value);
                    if (!rsCheck) {
                        this.isGoodsSerial = true;
                        this.goodsSerialError = '商品条码由5-15位数字或者字母组成';
                    } else {
                        this.isGoodsSerial = false;
                        this.goodsSerialError = '';
                    }
                }
                console.log(this.goodsSerialError);
                // this.prospec.goodsSerial = value;
            },
            confirmFill() {
                //确认填充
                if (this.tabledata.length == 0) {
                    this.$message.warning('没有可以被填充的规格！');
                    return;
                }
                if (
                    this.prospec.goodsInventory === '' ||
                    this.prospec.remindStock === '' ||
                    this.prospec.tightInventory === '' ||
                    this.prospec.price === '' ||
                    this.prospec.originalPrice === '' ||
                    this.prospec.commissionType === ''
                ) {
                    this.$message.warning('请填写完整的规格配置');
                    return;
                }
                if (this.prospec.commissionType == 0) {
                    //结算价
                    //当商品结算价不为空时，检验输入的商品进货价是否合法
                    if (this.isPurPrice) {
                        this.$message.warning(this.purPriceError);
                        return;
                    }
                } else {
                    //抽佣比例
                    //当商品抽佣比例不为空时，检验输入的商品进货价是否合法
                    if (this.isRate) {
                        this.$message.warning(this.commissionRateError);
                        return;
                    }
                }
                //当商品库存不为空时，校验商品库存的输入是否合法
                if (this.isGoodsInventory) {
                    this.$message.warning(this.goodsInventoryError);
                    return;
                }
                //当商品提醒库存不为空时，校验商品库存的输入是否合法
                if (this.isRemindStock) {
                    this.$message.warning(this.remindStockError);
                    return;
                }
                //当商品提醒库存不为空时，校验商品库存的输入是否合法
                if (this.isTightInventory) {
                    this.$message.warning(this.isTightInventoryError);
                    return;
                }
                //当商品价格不为空时，校验输入的价格是否合法
                if (this.isPrice) {
                    this.$message.warning(this.priceError);
                    return;
                }
                //当商品挂牌价不为空时，检验输入的商品原价是否合法
                if (this.isOriPrice) {
                    this.$message.warning(this.oriPriceError);
                    return;
                }

                //当商品条码不为空时，检验输入的商品条码是否合法
                if (this.isGoodsSerial) {
                    this.$message.warning(this.goodsSerialError);
                    return;
                }

                this.tabledata.forEach(item => {
                    for (let prop in item) {
                        if (prop == 'value' || prop == 'ids') {
                            continue;
                        } else {
                            item[prop] = this.prospec[prop];
                        }
                    }
                });
                console.log(this.tabledata);
                this.$message({
                    type: 'success',
                    message: '填充成功！'
                });
            },
            //校验价格
            testPriceMethod(value) {
                let flagTest = true;
                if (!validatPrice(value)) {
                    flagTest = false;
                } else if (value < 0.01 || value > 99999999.99) {
                    flagTest = false;
                } else {
                    flagTest = true;
                }
                return flagTest;
            },
            //校验价格
            testPriceMethod1(value) {
                let flagTest = true;
				if(value==0){
					flagTest = true;
				}else{
					if (!validatPrice(value)) {
					    flagTest = false;
					} else if (value < 0 || value > 99999999.99) {
					    flagTest = false;
					} else {
					    flagTest = true;
					}
				}
                return flagTest;
            },

            //校验输入的长，宽，高，重量
            testPropertyMethod(value) {
                let flagPropertyTest = false;

                if (!value) {
                    flagPropertyTest = false;
                } else {
                    if (!Number(value)) {
                        flagPropertyTest = false;
                    } else {
                        // const re = /^(?!00)(?:[0-9]{1,3}|1000)$/;
                        //  const rsCheck = re.test(value);
                        //  if (!rsCheck) {
                        //      flagPropertyTest = false;
                        //  } else {
                        //      flagPropertyTest = true;
                        //  }
                        if (0 < value && value < 1000) {
                            flagPropertyTest = true;
                        } else {
                            flagPropertyTest = false;
                        }
                    }
                }
                return flagPropertyTest;
            },

            //新增店铺分类
            goodsClassOpen() {
                this.dialogTableVisible = true;
                return false;
            },
            //新增运费模板
            templateFreightHandle() {
                this.$refs.templatefre.open();
            },
            // //商品详情pc
            // getEditcont(val) {
            // 	this.groupData.goodsDetails = val;
            // },
            //商品详情h5
            getEditconth5(val) {
                this.groupData.goodsDetailsH5 = val;
            },
            getTransType(id) {
                //获取运费模板详情
                viewTemplate(id).then(res => {
                    if (res.data.code == 200) {
                        console.log(res.data.data);
                        this.transType = res.data.data.transType;
                    }
                });
            },
            handleSubmit() {
                this.submitLoading = true;
                // //没编辑就还用之前的商品可见范围，编辑过了就处理下传参
                if (this.isEditSoRange) {
                    if (this.mineStatusValue.length > 0) {
                        this.groupData.goodsSoRange = [];
                        this.mineStatusValue.forEach((item, index) => {
                            this.groupData.goodsSoRange.push(item.id);
                        });
                    }
                }
                console.log(this.groupData.goodsSoRange);
                setTimeout(() => {
                    this.submitLoading = false;
                }, 1000);
                //选择商品分类
                // if (this.goodsclassname == '') {
                // 	this.$message.error('请选择商品分类');
                // 	return;
                // }
                if (!this.goodsClassId) {
                    this.$message.error('请选择商品类目');
                    return;
                }
				
                // if (!this.groupData.goodsClassFourId){
                //     this.$message.error('请选择税务品类名称');
                //     this.submitLoading = false;
                //     return;
                // }
                if (!this.groupData.goodsName) {
                    this.$message.error('请输入商品名称');
                    this.submitLoading = false;
                    return;
                }
				if(this.mineStatusValue.length==0){
					this.$message.error('请选择商品可见范围');
					return;
				}
                if (this.groupData.goodsPhotos.length < 1) {
                    this.$message.error('最少上传1张图片');
                    return;
                }

                if (this.groupData.inventoryType == 'spec' && this.tabledata.length == 0) {
                    this.$message.error('请配置商品规格！');
                    return;
                }
                console.log(this.tabledata);
				const re = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,2})?$/;
                if (this.groupData.inventoryType == 'spec') {
                    //规格配置
                    let flagError = '';
                    let flag = this.tabledata.some(item => {
                        if (!item.goodsInventory && item.goodsInventory != 0) {
                            flagError = '库存不能为空';
                            return true;
                        }
                        if (!item.remindStock && item.remindStock != 0) {
                            flagError = '提醒库存量不能为空';
                            return true;
                        }
                        if (!item.tightInventory && item.tightInventory != 0) {
                            flagError = '提醒库存紧张量不能为空';
                            return true;
                        }
                        if (item.price == 0 || item.originalPrice == 0) {
                            flagError = '商城售价/商品挂牌价必须是0.01-99999999.99之间的数字';
                            return true;
                        }
                        if (!item.price || !item.originalPrice) {
                            flagError = '商城售价/商品挂牌价不能为空';
                            return true;
                        }
                        // console.log(item.commissionType )
                        // if(item.commissionType == ''  ){
                        // 	flagError='请选择结算方式'
                        // 	return true
                        // }
                        if (item.commissionType == 1) {
							
                            //抽佣
                            if (!re.test(item.commissionRate)) {
								flagError = '抽佣比例必须是0.01-1之间的数字';
								return true;
                                // return false
                            } else if (item.commissionRate < 0.01 || item.commissionRate > 1) {
                                flagError = '抽佣比例必须是0.01-1之间的数字';
                                return true;
                            } 
							// else {
       //                          flagError = '抽佣比例不能为空';
       //                          return true;
       //                      }
                        }
                        if (item.commissionType == 0) {
                            //结算价
                            if (item.purchasePrice || item.purchasePrice == 0) {
                                // return false
                            } else {
                                flagError = '结算价不能为空';
                                return true;
                            }
                        }
                        let reg = /^[A-Za-z0-9]{5,16}$/;
                        if (!reg.test(item.goodsSerial) && item.goodsSerial) {
                            flagError = '商品条码由5-15位数字或者字母组成';
                            return true;
                        }
                        // else{
                        // return false
                        // }
                        //结算价可为0  加校验
                    });
                    if (flag) {
                        this.$message.warning(flagError);
                        return;
                    }
                }
                if (this.groupData.inventoryType == 'all') {
                    //全局配置
                    //当商品库存不为空时，校验商品库存的输入是否合法
                    if (this.isGoodsInventory) {
                        this.$message.warning(this.goodsInventoryError);
                        return;
                    }
                    //当商品提醒库存不为空时，校验商品库存的输入是否合法
                    if (this.isRemindStock) {
                        this.$message.warning(this.remindStockError);
                        return;
                    }
                    //当商品提醒库存不为空时，校验商品库存的输入是否合法
                    if (this.isTightInventory) {
                        this.$message.warning(this.isTightInventoryError);
                        return;
                    }
                    //当商品价格不为空时，校验输入的价格是否合法
                    if (this.isPrice) {
                        this.$message.warning(this.priceError);
                        return;
                    }
                    //当商品挂牌价不为空时，检验输入的商品原价是否合法
                    if (this.isOriPrice) {
                        this.$message.warning(this.oriPriceError);
                        return;
                    }
                    //当商品条码不为空时，检验输入的商品条码是否合法
                    if (this.isGoodsSerial) {
                        this.$message.warning(this.goodsSerialError);
                        return;
                    }
                    /*if(!this.groupData.goodsSerial){
					this.$message.warning('商品条码不能为空');
					return;
				}*/
                    if (!this.groupData.goodsInventory && this.groupData.goodsInventory != 0) {
                        this.$message.warning('库存不能为空');
                        return;
                    }
                    if (!this.groupData.remindStock && this.groupData.remindStock != 0) {
                        this.$message.warning('提醒库存量不能为空');
                        return;
                    }
                    if (!this.groupData.tightInventory && this.groupData.tightInventory != 0) {
                        this.$message.warning('提醒库存紧张量不能为空');
                        return;
                    }
                    if (!this.groupData.originalPrice || !this.groupData.price) {
                        this.$message.warning('价格/商品挂牌价不能为空');
                        return;
                    }
                    if (this.groupData.originalPrice < 0.01 || this.groupData.originalPrice > 99999999.99 || this.groupData.price < 0.01 || this.groupData.price > 99999999.99) {
                        this.$message.warning('价格/商品挂牌价必须是0.01-99999999.99之间的数字');
                        return;
                    }
                    if (this.groupData.commissionType == 1) {
                        //抽佣比例
                        //当商品抽佣比例不为空时，检验输入的商品进货价是否合法
                        if (this.isRate) {
                            this.$message.warning(this.commissionRateError);
                            return;
                        }
                        if (!this.groupData.commissionRate) {
                            this.$message.warning('抽佣比例不能为空');
                            return;
                        }
                        if (!re.test(this.groupData.commissionRate)) {
                            this.$message.warning('抽佣比例必须是0.01-1之间的数字');
                            return;
                        }
						
                        if (this.groupData.commissionRate < 0.01 || this.groupData.commissionRate > 1) {
                            this.$message.warning('抽佣比例必须是0.01-1之间的数字');
                            return;
                        }
                    } else {
                        //结算价
                        //当商品结算价不为空时，检验输入的商品进货价是否合法
                        if (this.isPurPrice) {
                            this.$message.warning(this.purPriceError);
                            return;
                        }
                        if (!this.groupData.purchasePrice && this.groupData.purchasePrice != 0) {
                            this.$message.warning('结算价不能为空');
                            return;
                        }
                        if (this.groupData.purchasePrice === '') {
                            this.$message.warning('结算价不能为空');
                            return;
                        }
                    }
                }
                if (this.groupData.isSelfSupply == 1 && this.groupData.supplierId == '') {
                    this.$message.error('请选择供货商');
                    return;
                }
                if (this.groupData.choiceType == 0 && (this.groupData.transportId == '' || this.groupData.transportId == null)) {
                    this.$message.error('运费模板不能为空');
                    return;
                } else if (this.transType == 1 && this.groupData.goodsWeight == null) {
                    //根据运费模板判断商品属性是否必填
                    this.$message.error('商品重量不能为空');
                    return;
                } else if (this.transType == 2 && this.goodsVolume == null) {
                    this.$message.error('商品体积不能为空');
                    return;
                }
                //H5描述不能为空，
                // if (this.groupData.goodsDetails == '' || this.groupData.goodsDetails == null || this.groupData.goodsDetails == undefined) {
                // 	this.$message.error('PC商品描述不能为空');
                // 	return;
                // }

                if (this.groupData.goodsDetailsH5 == '' || this.groupData.goodsDetailsH5 == null || this.groupData.goodsDetailsH5 == undefined) {
                    this.$message.error('H5商品描述不能为空');
                    return;
                }
                //商品权重
                let res = /^\+?[1-9][0-9]*$/;
                if (!this.groupData.goodsSort) {
                    this.$message.error('权重不能为空');
                    return;
                } else if (!res.test(this.groupData.goodsSort)) {
                    this.$message.error('值为大于0小于999的整数');
                    return;
                } else if (parseInt(this.groupData.goodsSort) < 0 || parseInt(this.groupData.goodsSort) > 999) {
                    this.$message.error('权重要大于0小于999');
                    return;
                }
                //如果输入的有商品属性，长宽高等，也要交验
                if (this.groupData.goodsLength) {
                    //如果商品的长输入不为空的话，就校验它
                    if (!this.testPropertyMethod(this.groupData.goodsLength)) {
                        this.$message.error('商品长度需要大于0小于1000');
                        return;
                    }
                }

                if (this.groupData.goodsWidth) {
                    //如果商品的宽输入不为空的时候，就校验它
                    if (!this.testPropertyMethod(this.groupData.goodsWidth)) {
                        this.$message.error('商品宽度需要大于0小于1000');
                        return;
                    }
                }

                if (this.groupData.goodsHeight) {
                    //如果商品的高不为空的话，就校验它
                    if (!this.testPropertyMethod(this.groupData.goodsHeight)) {
                        this.$message.error('商品高度需要大于0小于1000');
                        return;
                    }
                }

                if (this.groupData.goodsWeight) {
                    //如果商品的重量不为空的话，就校验它
                    if (!this.testPropertyMethod(this.groupData.goodsWeight)) {
                        this.$message.error('商品重量需要大于0小于1000');
                        return;
                    }
                }
                this.naturalSpecList.forEach((item, index) => {
                    this.groupData.goodsPropertyIds.push(this.groupData['naturalSelData' + index]);
                });
                let specMap = this.localSpec();
                //禁止重复提交
                this.isDisabled = true;
                let AddGoodsFinishParam = {
                    goods: {
                        id: this.goodsId,
                        goodsName: this.groupData.goodsName,
                        distributionAreaId: this.groupData.distributionAreaId,
                        goodsClassId: this.goodsClassId,
                        goodsBrandId: this.groupData.goodsBrandId,
                        goodsClassFourId:this.groupData.goodsClassFourId,
                        choiceType: this.groupData.choiceType,
                        goodsLabel: this.groupData.goodsLabel.toString() || '',
                        goodsServeGuarantee: this.groupData.goodsServeGuarantee.toLocaleString(),
                        goodsSoRange: this.groupData.goodsSoRange.toString(),
                        goodsMainPhotoUrl: this.groupData.goodsPhotos[0],
                        supplierId: this.groupData.supplierId, //供货商
                        transportId: this.groupData.transportId, //运费模板
                        storeRecommend: this.groupData.storeRecommend, //商品推荐
                        goodsSort: this.groupData.goodsSort, //权重
                        inventoryType: this.groupData.inventoryType, //配置(全局/规格)
                        isSelfMention: this.groupData.isSelfMention == 0 ? false : true, //是否自提
                        storeWillCallId: this.groupData.storeWillCallId || '', //自提点
                        userGoodsClassId: this.value[1] //店铺分类
                    },
                    value: this.groupData.value, //商品规格
                    goodsInventory: this.groupData.goodsInventory, //商品库存
                    remindStock: this.groupData.remindStock, //提醒库存量
                    tightInventory: this.groupData.tightInventory || null, //提醒库存紧张量
                    goodsPhotosArr: this.groupData.goodsPhotos,
                    goodsVideoArr: this.groupData.goodsVideo,
                    goodsSerial: this.groupData.goodsSerial || '', //商品条码
                    purchasePrice: this.groupData.purchasePrice, //结算价
                    commissionType: this.groupData.commissionType, //结算方式
                    commissionRate: this.groupData.commissionRate, //抽佣比例
                    commissionValue: this.groupData.commissionValue, //抽佣值
                    originalPrice: this.groupData.originalPrice, //挂牌价
                    price: this.groupData.price, //商品价格
                    goodsLength: this.groupData.goodsLength, //长
                    goodsWidth: this.groupData.goodsWidth, //宽
                    goodsHeight: this.groupData.goodsHeight, //高
                    goodsVolume: this.goodsVolume, //体积
                    goodsWeight: this.groupData.goodsWeight, //重量
                    //goodsDetails: this.groupData.goodsDetails, //商品详情
                    goodsDetailsH5: this.groupData.goodsDetailsH5, //商品详情H5
                    intentoryDetails: this.tabledata, //规格配置
                    goodsPropertyIds: this.groupData.goodsPropertyIds,
                    goodsClassSpecIds: this.goodsClassSpecIds,
                    saleSpecMap: specMap[0], //自然属性列表, 文字描述
                    saleSpecMapImg: specMap[1] //自然属性列表，图片路径
                };
                console.log(AddGoodsFinishParam);
                this.isDisabled = false;
                // return;
                // this.$refs['objFrom'].validate(valid => {
                // 	if (valid) {				} else {
                // 		this.$message({
                // 			type: 'warning',
                // 			message: '请填写必要信息'
                // 		});
                // 		this.isDisabled = false;
                // 		return false;
                // 	}
                // });
                submitdata(AddGoodsFinishParam).then(res => {
                    if (res.data.code == 200) {
                        if (this.isPublish == true) {
                            this.dialogSuccessVisible = true;
                        } else {
                            this.$message.success('操作成功！');
                            // 发布消息给页面通知操作完成
                            this.$EventBus.$emit('finishhandle', true);
                        }
                    } else {
                        // this.$EventBus.$emit('finishhandle', false);
                        this.$message.error(res.data.message);
                        this.isDisabled = false;
                        return false;
                    }
                });
            },
            //包装自然属性，为了保存商品时让后台保存商品的修改后的属性值
            localSpec() {
                let objValue = {};
                let objImg = {};
                // let saleSpecS=this.saleSpecList;
                // for(let i=0;i<saleSpecS.length;i++){
                // 	let specChild=this.saleSpecList[i].childrenNodes;
                // 	for(let j=0;j<specChild.length;j++){
                // 		obj[specChild[j].id]=specChild[j].specpValue;
                // 	}
                // }
                let saleSpecS = this.specSelectData;
                for (let i = 0; i < saleSpecS.length; i++) {
                    objValue[saleSpecS[i].id] = saleSpecS[i].specpValue;
                    objImg[saleSpecS[i].id] = saleSpecS[i].specImageUrl;
                }
                let resultDate = [];
                resultDate.push(objValue);
                resultDate.push(objImg);
                return resultDate;
            }
        },
        mounted() {
            this.signOptions.forEach(item => {
                item.disabled = true; //可选
                item.childrenNodes.forEach(obj => {
                    obj.disabled = true; //可选
                    obj.childrenNodes.forEach(nodes => {
                        nodes.disabled = true; //可选
                        nodes.childrenNodes.forEach(child=>{
                            child.disabled = true; //可选
                        })
                    });
                });
            });
            this.isFirst = true
            this.groupHeights = [];
            let doms = document.getElementsByClassName('avue-group');
            for (let i = 0, len = doms.length; i < len; i++) {
                this.groupHeights.push(doms[i].offsetTop);
            }
            //获取浏览器窗口高度
            let clientHeight = document.body.clientHeight; // -114px
            document.getElementById('avue-view').style.height = clientHeight - 114 + 'px';
            document.getElementsByClassName('el-card')[0].style.height = clientHeight - 114 + 'px';
            document.getElementsByClassName('el-card__body')[0].style.height = clientHeight - 114 + 'px';
            document.getElementsByClassName('el-card__body')[0].style.boxSizing = 'border-box';
            let contentHeight = document.getElementById('avue-view').offsetHeight;
            document.getElementsByClassName('scrollView')[0].style.height = contentHeight - 100 + 'px';
            document.getElementsByClassName('scrollView')[0].style.overflowY = 'scroll';
        }
    };
</script>
<style lang="scss" scoped>
    /*.checkimg {*/
    /*    width: 20px;*/
    /*    height: 20px;*/
    /*}*/

    .basic-container {
        height: 100%;
        overflow: hidden;
    }

    .basic-container {
        height: 100%;
    }

    .el-card__body {
        height: 100% !important;
    }

    .protitle {
        font-size: 12px;
        color: #606266;
    }

    .imgContainer {
        box-sizing: border-box;
        display: flex;
        justify-content: flex-start;
        flex-flow: column nowrap;
    }

    .upload {
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }

    .previewPic {
        display: flex;
        justify-content: flex-start;
        width: 100%;
        overflow: scroll;
    }

    .handlebox {
        width: 100%;
        height: 15px;
        line-height: 15px;
        display: flex;
        justify-content: space-around;
    }

    .tsmsg {
        font-size: 10px;
        color: #999;
        margin: 0px;
        width: 250px;
        padding-left: 10px;
    }

    .handlebox img {
        cursor: pointer;
    }

    .specitem {
        display: flex;
        justify-content: flex-start;
    }

    .goodsSpecConfig {
        display: flex;
        flex-flow: column nowrap;
        justify-content: flex-start;
        
    }

    .specbox {
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .ckeckitem {
        width: calc(100% - 80px);
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 0 0 20px;
    }

    .items {
        display: flex;
        align-items: center;
        justify-content: space-around;
        min-width: 110px;
        padding: 0 10px;
        box-sizing: border-box;
    }

    .checkimg {
        width: 30px;
        padding: 0 5px;
        height: 30px;
        object-fit: cover;
        cursor: pointer;
    }
    .image-slot {
        width: 16px;
        padding: 0 5px;
        height: 16px;
        object-fit: cover;
        /*cursor: pointer;*/
        .el-icon-picture-outline{
            font-size: 25px;
            // margin-top: -5px;
        }
    }
    table,
    th,
    td {
        border: 1px solid #dcdfe6;
        vertical-align: middle;
        text-align: center;
    }

    .spectab {
        width: 140px;
        display: table-cell;
        vertical-align: middle;
        font-size: 13px;
        height: 20px;
        line-height: 20px;
        padding: 8px;
    }

    /*    .ipttable {
      width: 50px;
    }*/
    table tr {
        line-height: 40px;
    }

    .specsBox {
        height: 30px;
        line-height: 30px;
        border: 0;
        background: transparent;
        text-align: center;
        width: 80px;
    }

    .storebox {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sizebox {
        display: flex;
        justify-content: flex-start;
        flex: 1;
        flex-wrap: wrap;
    }

    .fromRow {
        width: 200px;
        display: flex;
        margin-bottom: 10px;
    }

    .boxSuccess {
        text-align: center;
    }

    .boxSuccess a {
        border: 0;
        color: #0f88eb;
        outline: none;
    }

    .boxSuccess a:hover {
        text-decoration: underline;
    }

    .icon-success {
        color: #0f88eb;
        height: 80px;
        font-size: 80px !important;
        text-align: center;
        vertical-align: middle;
    }

    .tip-success {
        height: 50px;
        line-height: 40px;
        color: #666;
        font-size: 15px;
        text-align: center;
        padding-bottom: 60px;
    }

    //视频图片外框
    .demo-image__preview {
        padding-top: 15px;
    }

    .avatar {
        width: 300px;
        height: 300px;
        border: 1px solid #f2f2f2;
    }
    .el-icon-picture-outline{
        font-size: 100px;
    }
	/deep/ .el-tag.el-tag--info .el-tag__close {
		color: #909399;
		display: none!important;
	}
</style>
